var softkeysClass = { new : func (device, node, role) { var m = { parents: [ softkeysClass ] }; m.node = node; m.device = device; m.role = role; m.path = []; return m; }, clean : func { # deletes unsed bindings foreach (var b; keys(me.bindings)) if (b != me.role) delete(me.bindings, b); }, SoftKey : func (n, a) { # released key not yet managed if (a == 1) return; var key = me.device.display.screenElements[sprintf("SoftKey%02i-text",n)].get('text'); if (key == '' or key == nil) return; var path = keyMap[me.role]; foreach(var p; me.path) { if (contains(path, p)) path = path[p]; else break; } var bindings = me.bindings[me.role]; foreach(var p; me.path) { if (contains(bindings, p)) bindings = bindings[p]; else break; } if (contains(path, key)) { append(me.path, key); me.device.display.updateSoftKeys(); } elsif (contains(bindings, key)) { call(bindings[key], [], me); } elsif (key == 'BACK') { pop(me.path); me.device.display.updateSoftKeys(); } else print(me.device.role ~ '/' ~ key ~ ' : not yet implemented'); }, bindings : { PFD : { INSET: { OFF: func { pop(me.path); me.device.display.updateSoftKeys(); }, }, PFD: { 'STD BARO': func { pop(me.path); me.device.display.updateSoftKeys(); }, 'AOA/WIND' : { WIND : { OPTN1 : func { me.device.display._winddata_optn = 1; me.device.display.screenElements['WindData'].show(); me.device.display.screenElements['WindData-OPTN1'].show(); me.device.display.screenElements['WindData-OPTN1-HDG'].show(); me.device.display.screenElements['WindData-OPTN2'].hide(); me.device.display.updateWindData(); }, OPTN2 : func { me.device.display._winddata_optn = 2; me.device.display.screenElements['WindData'].show(); me.device.display.screenElements['WindData-OPTN1'].hide(); me.device.display.screenElements['WindData-OPTN2'].show(); me.device.display.screenElements['WindData-OPTN2-symbol'].show(); me.device.display.screenElements['WindData-OPTN2-headwind'].show(); me.device.display.screenElements['WindData-OPTN2-crosswind'].show(); me.device.display.updateWindData(); }, OFF : func { me.device.display._winddata_optn = 0; me.device.display.screenElements['WindData'].hide(); me.device.display.screenElements['WindData-OPTN1'].hide(); me.device.display.screenElements['WindData-OPTN2'].hide(); }, }, }, }, XPDR: { CODE: { IDENT: func { me.path = []; me.device.display.updateSoftKeys(); }, BACK: func { me.path = []; me.device.display.updateSoftKeys(); }, }, }, }, MFD : { ENGINE: { FUEL: { UNDO: func { pop(me.path); me.device.display.updateSoftKeys(); }, ENTER: func { pop(me.path); me.device.display.updateSoftKeys(); }, }, ENGINE: func { me.path = []; me.device.display.updateSoftKeys(); }, }, }, }, };