On Jan 2, 2011, at 8:45 PM, OKB (not okblacke) wrote:

>    Ah, I now tried doing self.Application.bindEvent instead, and that 
> worked.  However, it's not ideal for my purpose, since I assume it's 
> setting it globally for the app.
> 
>       The deal is that I have a dPageFrameNoTabs where, based on stuff 
> the user does, focus changes to a new panel.  The individual pages are 
> dPanels.  The page-frame occupies the entire form, so the entirety of 
> the interface the user sees is always a single panel of the form.  So is 
> there a way to bind a KeyEvent in such a way that it is caught only when 
> a certain panel is chosen?  Or would I have to bind it on the App and 
> then manually check what panel is selected?


        Another option if you don't need to catch every possible keypress is to 
use the bindKey() method. This does the equivalent of a menu shortcut, so it 
works from anywhere in the form. As a result, I usually call bindKey() at the 
form level.

        Let's say you want to, among other things do something when the user 
presses Ctrl+Y on a particular page. In your form's afterInit(), add:

self.bindKey("ctrl+y", self.keypressHandler)

        Then create the handler. It's generally easier to create a single 
handler that determines which key combo was pressed where, and delegate the 
action from that.

def keypressHandler(self, evt):
        code = evt.keyCode
        shift = evt.shiftDown
        ctrl = evt.controlDown
        obj = evt.EventObject
        if code = ord("Y"):
                if self.noTabs.SelectedPageNumber = 2:
                        # the page you want ctrl-y to be active on
                        self.doSomeBehavior()


-- Ed Leafe



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to