Ignore:
Timestamp:
05/12/12 11:52:03 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The hotkey handling works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/gui.py

    r164 r168  
    152152        self._lastLoadedPIREP = None
    153153
     154        self._hotkeySetID = None
     155
    154156    @property
    155157    def mainWindow(self):
     
    320322            self._wizard.connected(fsType, descriptor)
    321323        self._reconnecting = False
     324        self._listenHotkeys()
    322325
    323326    def connectionFailed(self):
     
    402405        """Disconnect from the simulator if connected."""
    403406        self.stopMonitoring()
     407        self._clearHotkeys()
    404408
    405409        if self._connected:
     
    875879    def _editPreferences(self, menuItem):
    876880        """Callback for editing the preferences."""
     881        self._clearHotkeys()
    877882        self._preferences.run(self.config)
    878883        self._setupTimeSync()
     884        self._listenHotkeys()
    879885
    880886    def _setupTimeSync(self):
     
    11061112        if callback is not None:
    11071113            callback(returned, result)
     1114
     1115    def _listenHotkeys(self):
     1116        """Setup the hotkeys based on the configuration."""
     1117        if self._hotkeySetID is None and self._simulator is not None:
     1118            self._hotkeySetID = \
     1119                self._simulator.listenHotkeys([self.config.pilotHotkey,
     1120                                               self.config.checklistHotkey],
     1121                                              self._handleHotkeys)
     1122
     1123    def _clearHotkeys(self):
     1124        """Clear the hotkeys."""
     1125        if self._hotkeySetID is not None:
     1126            self._hotkeySetID=None
     1127            self._simulator.clearHotkeys()
     1128
     1129    def _handleHotkeys(self, id, hotkeys):
     1130        """Handle the hotkeys."""
     1131        if id==self._hotkeySetID:
     1132            print "gui.GUI._handleHotkeys", hotkeys
Note: See TracChangeset for help on using the changeset viewer.