Closed Alexey-T closed 3 years ago
тест АПИ дает нормалные ивенты
import os
from cudatext import *
from cudatext_keys import *
class Command:
ct=False
def on_key(self, ed_self, key, state):
if 'c' in state: self.ct=True
def on_key_up(self, ed_self, key, state):
self.ct=False
def on_mouse_stop(self, ed_self, x, y):
if self.ct:
print('Ctrl+stop %s:%s'%(x,y))
Я специально из-за этого добавил опцию отключения hover - enable_mouse_hover
, чтобы только по команде :)
Одна небольшая проблема с вашим решением - как обычно в таких случаях я не получу on_key_up
если окно потеряет фокус... это конечно лучше чем текущая ситуация, но может возможно как-то лучше сделать? (у меня мало надежды, так как это проблема везде :) )
я не получу on_key_up если окно потеряет фокус
on_app_deactivate поможет? а как лучше сделать,не пойму?
on_app_deactivate поможет?
тут я думаю лучше застрять в self.ct=True
, так что нет.
а как лучше сделать,не пойму?
get_pressed_keys()
:)
app_proc has
PROC_GET_KEYSTATE: Returns state of pressed keyboard keys and mouse buttons. String result has chars:
"c" for Ctrl
"a" for Alt
"s" for Shift
"m" for Meta (Windows key)
"L" for left mouse button
"R" for right mouse button
"M" for middle mouse button
добавил
Хорошо работает, пауза от on_mouse_stop()
позволяет нажать Контрол когда уже навел курсор, а я уже думал как паузу добавить :)
это позволит не раздражать юзера когда он просто двигает мышкой, а у него попАпы лезут. а также поправить вызовы mouse_stop когда он идет в top menu.
on_key(self, ed_self, key, state): Called when user presses a key in editor. Param "key" is int key code; values are listed in the module cudatext_keys. Param "state" is string of chars: "a" if Alt pressed, "c" if Ctrl pressed, "s" if Shift pressed, "m" if Meta (Windows-key) pressed. Method can return False to disable key processing, other return value is ignored.
on_key_up(self, ed_self, key, state): Called when user depresses a key in editor. Params meaning is the same as in "on_key". Currently called only for Ctrl/Shift/Alt keys (to not slow down).