1. RE: Accelerator Keys not working . . .
- Posted by Derek Parnell <ddparnell at bigpond.com> May 23, 2001
- 456 views
> -----Original Message----- > From: jjnick at cvn.com [mailto:jjnick at cvn.com] > Sent: Thursday, 24 May 2001 9:34 AM > To: EUforum > Subject: Accelerator Keys not working . . . > > Okay, maybe there is something wrong somewhere . . . I have > a pushbutton > called "Remove", the accelerator being "Alt-R", yet the > button is not pushed > when I press "Alt-R", the focus just changes to the button . . . This > happens to all my pushbuttons in the window . . . In other > words, the focus > changes to the > desired button, but the button is not pressed . . . Firstly, when you say "the button is not pressed", do you mean that the button on the screen does not LOOK like it is being pressed. That is, you cannot see it being pushed down and then released? If this is what you are referring to, then you are correct. The visual effect of pushing the button only occurs when the left mouse button is pressed on the button. This is controlled by Windows and not win32lib. However, if you are meaning that the onClick handler is not being invoked, then I cannot reproduce the effect on my system. Here is a little program I just used to test accelerator keys. It works fine in version v0.55.0 and v0.55.1. By "fine" I mean that I get the expected message in the statusbar when I mouse-click on the buttons, and when I press Alt-A/B/C/F9, and when I use TAB+SPACEBAR. If you have defined a handler for Click events, make sure you have spelt the routine name correctly in the routine_id() function. This is a mistake I often make and it frustrates me when I my handler routine gets ignored. ------------------------------- include win32lib.ew without warning constant title = "BUTTON PUSHER " & sprintf("V%d.%d.%d", { Win32LibVersion[1], Win32LibVersion[2], Win32LibVersion[3]}), win = create(Window, title, 0, 0, 0, 300, 300, 0), sb = create(StatusBar, "", win, 0, 0, 0, 0, 0), btn1 = create(PushButton, "&A", win, 10, 10, 50, 25, 0), btn2 = create(PushButton, "&B", win, 10, 40, 50, 25, 0), btn3 = create(PushButton, "&C", win, 10, 70, 50, 25, 0) procedure clicks(integer self, integer event, sequence parms) setText(sb, sprintf("Button = '%s' (%d)", {getText(self), self})) end procedure registerHotKey(btn2, VK_F9) setHandler({btn1,btn2,btn3}, w32HClick, routine_id("clicks")) WinMain(win, Normal) -------------------------------- what happens when you try this program? What version of the library are you using? ----------- cheers, Derek Parnell Senior Design Engineer Global Technology Australasia Ltd dparnell at glotec.com.au ---------------------
2. RE: Accelerator Keys not working . . .
- Posted by Derek Parnell <ddparnell at bigpond.com> May 24, 2001
- 434 views
> -----Original Message----- > From: jjnick at cvn.com [mailto:jjnick at cvn.com] > Sent: Friday, 25 May 2001 11:47 AM > To: EUforum > Subject: Re: Accelerator Keys not working . . . > The code provided doesn't work, I'm using win32lib v0.50 . . . Then upgrade to 0.55.1 http://users.bigpond.com/ddparnell/euphoria/euphoria.htm ----------- cheers, Derek Parnell Senior Design Engineer Global Technology Australasia Ltd dparnell at glotec.com.au ---------------------
3. RE: Accelerator Keys not working . . .
- Posted by Derek Parnell <ddparnell at bigpond.com> May 24, 2001
- 437 views
> -----Original Message----- > From: jjnick at cvn.com [mailto:jjnick at cvn.com] > Sent: Friday, 25 May 2001 3:32 PM > To: EUforum > Subject: Re: Accelerator Keys not working . . . > > > procedure clicks(integer self, integer event, sequence parms) > > setText(sb, sprintf("Button = '%s' (%d)", > {getText(self), self})) > > end procedure > > > > setHandler({btn1,btn2,btn3}, w32HClick, routine_id("clicks")) > > > > So, for every button I have an accelerator for, I have to > call a unique > procedure which then calls the appropriate "onClick" procedure? > No. This is just ONE way you can do it. Here is another.... procedure OrderPizza(integer self, integer event, sequence parms) -- The user wants to order a pizza. . . . end procedure setHandler(btn1, w32HClick, routine_id("OrderPizza")) procedure TurnLeft(integer self, integer event, sequence parms) -- Quick! Turn left now! . . . end procedure setHandler(btn2, w32HClick, routine_id("TurnLeft")) procedure WalkTheDog(integer self, integer event, sequence parms) -- The wife wants you to mow the lawns. . . . end procedure setHandler(btn3, w32HClick, routine_id("WalkTheDog")) My example was just a shorthand way of doing ... setHandler(btn1, w32HClick, routine_id("clicks")) setHandler(btn2, w32HClick, routine_id("clicks")) setHandler(btn3, w32HClick, routine_id("clicks")) because I wanted all three buttons to invoke the same routine. Alternatively, I could have coded three routines, given them all different names but coded them to do the same thing. Note, when using the "setHandler" method of telling Win32lib what to do for an event, the procedure you code must ALWAYS take three parameters; integer self -- the ID of the control that invoked the handler, integer event -- the Win32lib name for the event, eg. "w32HClick", sequence parms -- a list of data that comes with the event. This varies with the type of event. See the docs for details. The use of setHandler(), instead of onXXX[], allows for changes to the internals of Win32lib without breaking existing code, allows app writers to create "generic" handlers if required, makes it easier for IDE writers to generate apps using Win32lib, makes it possible for developers to create new control types with their own event types, and they are invoked (slightly) faster. But that's just my opinion. ---------- cheers, Derek Parnell Senior Design Engineer Global Technology Australasia Ltd dparnell at glotec.com.au ---------------------
4. RE: Accelerator Keys not working . . .
- Posted by Derek Parnell <ddparnell at bigpond.com> May 25, 2001
- 430 views
> Thanks, by the way, I finally downloaded the newest version > of win32lib and > WOW, things really have changed, looks like for the better. > Only broke my > code in a few places. . . Well that just means we are not really trying, eh? ----------- cheers, Derek Parnell