def __init__(self): super(ShortcutBasicsExample, self).__init__() self.setSpacing(True) # Firstname input with an input prompt for demo clarity firstname = TextField('Firstname') firstname.setInputPrompt('ALT-SHIFT-F to focus') self.addComponent(firstname) # Add global shortcut that focuses the field firstname.addShortcutListener(FocusShortcut(firstname, KeyCode.F, ModifierKey.ALT, ModifierKey.SHIFT)) # Lastname input with an input prompt for demo clarity lastname = TextField('Lastname') lastname.setInputPrompt('ALT-SHIFT-L to focus') self.addComponent(lastname) # Add global shortcut that focuses the field lastname.addShortcutListener(FocusShortcut(lastname, KeyCode.L, ModifierKey.ALT, ModifierKey.SHIFT)) # Button with a simple click-listener enter = Button('Enter', EnterListener(self)) self.addComponent(enter) enter.setStyleName('primary') # make it look like it's default # Add global shortcut using the built-in helper enter.setClickShortcut(KeyCode.ENTER)
def __init__(self): super(ShortcutBasicsExample, self).__init__() self.setSpacing(True) # Firstname input with an input prompt for demo clarity firstname = TextField('Firstname') firstname.setInputPrompt('ALT-SHIFT-F to focus') self.addComponent(firstname) # Add global shortcut that focuses the field firstname.addShortcutListener( FocusShortcut(firstname, KeyCode.F, ModifierKey.ALT, ModifierKey.SHIFT)) # Lastname input with an input prompt for demo clarity lastname = TextField('Lastname') lastname.setInputPrompt('ALT-SHIFT-L to focus') self.addComponent(lastname) # Add global shortcut that focuses the field lastname.addShortcutListener( FocusShortcut(lastname, KeyCode.L, ModifierKey.ALT, ModifierKey.SHIFT)) # Button with a simple click-listener enter = Button('Enter', EnterListener(self)) self.addComponent(enter) enter.setStyleName('primary') # make it look like it's default # Add global shortcut using the built-in helper enter.setClickShortcut(KeyCode.ENTER)