adding repeater mode on mouse held down
This commit is contained in:
@@ -5,6 +5,7 @@ An onscreen keyboard for the mouse.
|
|||||||
* PyGObject
|
* PyGObject
|
||||||
* python-xlib
|
* python-xlib
|
||||||
* pyautogui
|
* pyautogui
|
||||||
|
* setproctitle
|
||||||
* fast-autocomplete[levenshtein]
|
* fast-autocomplete[levenshtein]
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
PyGObject
|
PyGObject
|
||||||
pyautogui
|
|
||||||
python-xlib
|
python-xlib
|
||||||
setproctitle
|
pyautogui
|
||||||
|
setproctitle
|
||||||
|
fast-autocomplete[levenshtein]
|
||||||
@@ -57,7 +57,7 @@ keys_json = {
|
|||||||
},
|
},
|
||||||
"row4": {
|
"row4": {
|
||||||
"pKeys": ['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '?'],
|
"pKeys": ['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '?'],
|
||||||
"sKeys": ['', '', '<', '>', '[', ']', '(', ')', '{', '}']
|
"sKeys": ['', '', '\\<', '>', '[', ']', '(', ')', '{', '}']
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,8 @@ class Backspace_Key(Key):
|
|||||||
super(Backspace_Key, self).__init__("Backspace", "Backspace", iscontrol=True)
|
super(Backspace_Key, self).__init__("Backspace", "Backspace", iscontrol=True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._clicked)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
def _clicked(self, widget = None):
|
|
||||||
typwriter.press_special_keys(self.get_label())
|
|
||||||
|
|
||||||
class Emoji_Key(Key):
|
class Emoji_Key(Key):
|
||||||
def __init__(self, emoji_popover):
|
def __init__(self, emoji_popover):
|
||||||
@@ -98,7 +96,8 @@ class Enter_Key(Key):
|
|||||||
self.set_vexpand(True)
|
self.set_vexpand(True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_press_special_key)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
|
|
||||||
|
|
||||||
############################# Bottom_Key_Row Keys #############################
|
############################# Bottom_Key_Row Keys #############################
|
||||||
@@ -115,7 +114,8 @@ class Space_Key(Key):
|
|||||||
super(Space_Key, self).__init__("Space", "Space", iscontrol=True)
|
super(Space_Key, self).__init__("Space", "Space", iscontrol=True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_press_special_key)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
|
|
||||||
class AT_Key(Key):
|
class AT_Key(Key):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -133,14 +133,16 @@ class Tab_Key(Key):
|
|||||||
super(Tab_Key, self).__init__("Tab", "Tab", iscontrol=True)
|
super(Tab_Key, self).__init__("Tab", "Tab", iscontrol=True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_press_special_key)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
|
|
||||||
class Del_Key(Key):
|
class Del_Key(Key):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Del_Key, self).__init__("Del", "Del", iscontrol=True)
|
super(Del_Key, self).__init__("Del", "Del", iscontrol=True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_press_special_key)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
|
|
||||||
class Ctrl_Key(Key):
|
class Ctrl_Key(Key):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -175,25 +177,29 @@ class Up_Key(Key):
|
|||||||
super(Up_Key, self).__init__("Up", "Up", iscontrol=True)
|
super(Up_Key, self).__init__("Up", "Up", iscontrol=True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_press_special_key)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
|
|
||||||
class Down_Key(Key):
|
class Down_Key(Key):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Down_Key, self).__init__("Down", "Down", iscontrol=True)
|
super(Down_Key, self).__init__("Down", "Down", iscontrol=True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_press_special_key)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
|
|
||||||
class Left_Key(Key):
|
class Left_Key(Key):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Left_Key, self).__init__("Left", "Left", iscontrol=True)
|
super(Left_Key, self).__init__("Left", "Left", iscontrol=True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_press_special_key)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
|
|
||||||
class Right_Key(Key):
|
class Right_Key(Key):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Right_Key, self).__init__("Right", "Right", iscontrol=True)
|
super(Right_Key, self).__init__("Right", "Right", iscontrol=True)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_press_special_key)
|
self.connect("button-press-event", self._do_press_special_key_repeater)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import gi
|
import gi
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import GLib
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ class Key(Gtk.Button or Gtk.ToggleButton):
|
|||||||
def __init__(self, primary = "NULL", secondary = "NULL", iscontrol=False):
|
def __init__(self, primary = "NULL", secondary = "NULL", iscontrol=False):
|
||||||
super(Key, self).__init__()
|
super(Key, self).__init__()
|
||||||
|
|
||||||
|
self.timer_id = None
|
||||||
self.iscontrol = iscontrol
|
self.iscontrol = iscontrol
|
||||||
self._primary_symbol = primary
|
self._primary_symbol = primary
|
||||||
self._secondary_symbol = secondary
|
self._secondary_symbol = secondary
|
||||||
@@ -28,10 +30,19 @@ class Key(Gtk.Button or Gtk.ToggleButton):
|
|||||||
event_system.subscribe("toggle_symbol_keys", self.toggle_symbol_keys)
|
event_system.subscribe("toggle_symbol_keys", self.toggle_symbol_keys)
|
||||||
|
|
||||||
def setup_signals(self):
|
def setup_signals(self):
|
||||||
self.connect("released", self._do_type)
|
self.connect("button-press-event", self._do_press)
|
||||||
|
self.connect("button-release-event", self._do_release)
|
||||||
self.connect("toggle-emoji-keys", self.toggle_emoji_keys)
|
self.connect("toggle-emoji-keys", self.toggle_emoji_keys)
|
||||||
|
|
||||||
def _do_type(self, widget = None):
|
def _do_press(self, widget = None, eve = None):
|
||||||
|
if self.timer_id:
|
||||||
|
GLib.source_remove(self.timer_id)
|
||||||
|
self.timer_id = None
|
||||||
|
|
||||||
|
self._do_type()
|
||||||
|
self.timer_id = GLib.timeout_add(200, self._do_type)
|
||||||
|
|
||||||
|
def _do_type(self, widget = None, eve = None):
|
||||||
key = self.get_label().strip()
|
key = self.get_label().strip()
|
||||||
if not self._is_emoji:
|
if not self._is_emoji:
|
||||||
typwriter.type(key)
|
typwriter.type(key)
|
||||||
@@ -41,13 +52,32 @@ class Key(Gtk.Button or Gtk.ToggleButton):
|
|||||||
typwriter.type('v')
|
typwriter.type('v')
|
||||||
typwriter.isCtrlOn = False
|
typwriter.isCtrlOn = False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _do_release(self, widget = None, eve = None):
|
||||||
|
if not self.timer_id: return
|
||||||
|
GLib.source_remove(self.timer_id)
|
||||||
|
self.timer_id = None
|
||||||
|
|
||||||
def _do_press_special_key(self, widget = None):
|
def _do_press_special_key(self, widget = None):
|
||||||
|
self._do_type_special_key(widget)
|
||||||
|
|
||||||
|
def _do_press_special_key_repeater(self, widget = None, eve = None):
|
||||||
|
if self.timer_id:
|
||||||
|
GLib.source_remove(self.timer_id)
|
||||||
|
self.timer_id = None
|
||||||
|
|
||||||
|
self._do_type_special_key()
|
||||||
|
self.timer_id = GLib.timeout_add(200, self._do_type_special_key)
|
||||||
|
|
||||||
|
def _do_type_special_key(self, widget = None):
|
||||||
key = self.get_label()
|
key = self.get_label()
|
||||||
if key in ["Ctrl", "Shift", "Alt"]:
|
if key in ["Ctrl", "Shift", "Alt"]:
|
||||||
ctx = widget.get_style_context()
|
ctx = widget.get_style_context()
|
||||||
ctx.remove_class("toggled_bttn") if ctx.has_class("toggled_bttn") else ctx.add_class("toggled_bttn")
|
ctx.remove_class("toggled_bttn") if ctx.has_class("toggled_bttn") else ctx.add_class("toggled_bttn")
|
||||||
|
|
||||||
typwriter.press_special_keys(key)
|
typwriter.press_special_keys(key)
|
||||||
|
return True
|
||||||
|
|
||||||
def toggle_symbol_keys(self, widget = None, eve = None):
|
def toggle_symbol_keys(self, widget = None, eve = None):
|
||||||
if not self.iscontrol:
|
if not self.iscontrol:
|
||||||
|
|||||||
Reference in New Issue
Block a user