Pārlūkot izejas kodu

refactoring hotkey naming to keyboard

Christoph Trappe 3 gadi atpakaļ
vecāks
revīzija
3deb87fff3
4 mainītis faili ar 10 papildinājumiem un 10 dzēšanām
  1. 3 3
      main.py
  2. 1 1
      nicegui/elements/keyboard.js
  3. 5 5
      nicegui/elements/keyboard.py
  4. 1 1
      nicegui/ui.py

+ 3 - 3
main.py

@@ -391,7 +391,7 @@ with example(get_decorator):
 
 
     ui.link('Try yet another route!', '/another/route/1')
     ui.link('Try yet another route!', '/another/route/1')
 
 
-with example(ui.hotkey):
+with example(ui.keyboard):
     def handle_keys(e):
     def handle_keys(e):
         if e.key == 'f' and not e.key.repeat:
         if e.key == 'f' and not e.key.repeat:
             if e.action.keyup:
             if e.action.keyup:
@@ -408,7 +408,7 @@ with example(ui.hotkey):
             elif e.key.down:
             elif e.key.down:
                 ui.notify('going down')
                 ui.notify('going down')
 
 
-    hotkeys = ui.hotkey(handle_keys)
-    ui.label('Key events can be caught globally by using the hotkey element.')
+    keyboard = ui.keyboard(handle_keys)
+    ui.label('Key events can be caught globally by using the keyboard element.')
 
 
 ui.run(port=8080)
 ui.run(port=8080)

+ 1 - 1
nicegui/elements/hotkey.js → nicegui/elements/keyboard.js

@@ -1,4 +1,4 @@
-Vue.component('hotkey', {
+Vue.component('keyboard', {
 	template: `<span v-bind:id="jp_props.id" :class="jp_props.classes" :style="jp_props.style"></span>`,
 	template: `<span v-bind:id="jp_props.id" :class="jp_props.classes" :style="jp_props.style"></span>`,
 	methods: {
 	methods: {
 		add_event_listeners() {
 		add_event_listeners() {

+ 5 - 5
nicegui/elements/hotkey.py → nicegui/elements/keyboard.py

@@ -5,24 +5,24 @@ from .element import Element
 from ..utils import handle_exceptions, provide_arguments
 from ..utils import handle_exceptions, provide_arguments
 
 
 
 
-class HotkeyView(CustomView):
+class KeyboardView(CustomView):
 
 
     def __init__(self, handle_keys: Callable):
     def __init__(self, handle_keys: Callable):
-        super().__init__('hotkey', __file__, activeJSEvents=['keydown', 'keyup', 'keypress'])
+        super().__init__('keyboard', __file__, activeJSEvents=['keydown', 'keyup', 'keypress'])
         self.allowed_events = ['keyboardEvent']
         self.allowed_events = ['keyboardEvent']
         self.style = 'display: none'
         self.style = 'display: none'
         self.initialize(temp=False, on_keyboardEvent=handle_exceptions(provide_arguments(handle_keys, 'key_data', 'event_type')))
         self.initialize(temp=False, on_keyboardEvent=handle_exceptions(provide_arguments(handle_keys, 'key_data', 'event_type')))
 
 
 
 
-class Hotkey(Element):
+class Keyboard(Element):
 
 
     def __init__(self, handle_keys: Callable = None):
     def __init__(self, handle_keys: Callable = None):
         """
         """
-        Hotkeys
+        Keyboard
 
 
         Adds global keyboard event tracking.
         Adds global keyboard event tracking.
 
 
         :param handle_keys: callback to be executed when keyboard events occur.
         :param handle_keys: callback to be executed when keyboard events occur.
         """
         """
 
 
-        super().__init__(HotkeyView(handle_keys=handle_keys))
+        super().__init__(KeyboardView(handle_keys=handle_keys))

+ 1 - 1
nicegui/ui.py

@@ -36,7 +36,7 @@ class Ui:
     from .elements.row import Row as row
     from .elements.row import Row as row
     from .elements.column import Column as column
     from .elements.column import Column as column
     from .elements.card import Card as card
     from .elements.card import Card as card
-    from .elements.hotkey import Hotkey as hotkey
+    from .elements.keyboard import Keyboard as keyboard
     from .elements.card import CardSection as card_section
     from .elements.card import CardSection as card_section
 
 
     from .timer import Timer as timer
     from .timer import Timer as timer