Re: [orca-list] Detecting Double Key Press in orca-customizations.py



Hi Storm:

When you create a keybinding, you can pass an option click count parameter to the constructor. Here's an example from http://git.gnome.org/cgit/orca/tree/src/orca/default.py#n1600 that adds a double click:

keyBindings.add(
keybindings.KeyBinding(
"i",
settings.defaultModifierMask,
settings.ORCA_MODIFIER_MASK,

self.inputEventHandlers["reviewSpellCurrentLineHandler"],
2))

Hope this helps,

Will

On Dec 13, 2009, at 3:33 PM, Storm Dragon wrote:

Hi,
I know double key presses are used in things like the where a I function. I was wondering how to add this in to the customizations.py file too.  I tried writing my own, but although the code works in stand alone form, it doesn't work in the customizations file. Just for reference, here's the code:
import time
class countPresses:
    def __init__(self):
        self.clicks = 0
        self.now = time.time()

    def clickCount(self):
        if time.time() <= self.now + 0.75:
            self.clicks += 1
        self.now = time.time()
        if self.clicks > 2: self.clicks = 1
        return self.clicks

test = countPresses()
print str(test.clickCount())
print str(test.clickCount())
print str(test.clickCount())
time.sleep(3)
print str(test.clickCount())


--
Thoughts of a Dragon:
http://www.stormdragon.us/
What color dragon are you?
http://quizfarm.com/quizzes/new/alustriel07/what-color-dragon-would-you-be/



_______________________________________________
Orca-list mailing list
Orca-list gnome org
http://mail.gnome.org/mailman/listinfo/orca-list
Visit http://live.gnome.org/Orca for more information on Orca.
The manual is at http://library.gnome.org/users/gnome-access-guide/nightly/ats-2.html
The FAQ is at http://live.gnome.org/Orca/FrequentlyAskedQuestions
Netiquette Guidelines are at http://live.gnome.org/Orca/FrequentlyAskedQuestions/NetiquetteGuidelines
Log bugs and feature requests at http://bugzilla.gnome.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]