1. win32lib labels with hotkeys
- Posted by Derek Parnell <ddparnell at bigpond.com> May 27, 2003
- 384 views
I forgot to mention a new feature with win32lib. If you create a label control (LText, RText, CText) and place an '&' in its caption, then if the next field created is an input field, that input field has its own hotkey set to the label's hotkey. Thus ... lbl = create(RText, "&Customer:", Win, 5,10, 80, 25, 0) custname = create(EditBox, "", Win, 85, 10, 100, 25, 0) means that when the user presses Alt-C, the cursor jumps to the custname field. ------ Derek
2. Re: win32lib labels with hotkeys
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> May 30, 2003
- 384 views
On Tue, 27 May 2003 23:47:32 +1000, Derek Parnell <ddparnell at bigpond.com> wrote: > > >I forgot to mention a new feature with win32lib. > >If you create a label control (LText, RText, CText) and place an '&' in = its >caption, then if the next field created is an input field, that input = field >has its own hotkey set to the label's hotkey. Thus ... > > lbl =3D create(RText, "&Customer:", Win, 5,10, 80, 25, 0) > custname =3D create(EditBox, "", Win, 85, 10, 100, 25, 0) > >means that when the user presses Alt-C, the cursor jumps to the custname >field. I've just upgraded to 0.58.09. Prior to this mod I had several dummy fields eg Zsh=3Dcreate(LText,"&Z",win,0,0,0,0,0) to capture the Alt-Z, and an ongotfocus() routine to handle things manually. There isn't a specific control it applies to (it is actually a bitmap of four buttons, in a popup window, that I've carefully positioned over the titlebar, and I handle the mouse clicks in that region explicitly). I'm not surprised (and not upset either) they don't work no more. It's not exactly a common programming technique I think what I need to do is remove the &Z from the definition of Zsh and call registerHotKey(Zsh,"&Z"), right? A similar problem I have is: "&Size" "" <Slider> where there is a text field after the &Size which later gets set with "50%", "100%" etc. Which of the following would you recommend: 1) a change to win32lib to cope with this (leave vs_PreviousControl as is if it already contains a hotkey on a static field & there is no hotkey on the current static field) 2) just swap the define of my second field up. 3) merge the two labels. 4) something else Lastly, this might cause a problem for Judith's IDE. I don't use it so I don't know if it puts the fields in the right order. I often do eg create(text,x,10,10..) create(combo,x,30,7,..) to make them line up, so a strict sort on y then x co-ordinates would not work, Pete=20 <shrug> I don't want to think of how many ongotfocus(ltext) routines I'm going to have to find and delete. </shrug>
3. Re: win32lib labels with hotkeys
- Posted by Derek Parnell <ddparnell at bigpond.com> May 30, 2003
- 366 views
Don't do anything yet! I'll give it some thought and come up with a suitable 'fix' for you. It might take an hour or so. ----- Original Message ----- From: "Pete Lomax" <petelomax at blueyonder.co.uk> To: "EUforum" <EUforum at topica.com> Subject: Re: win32lib labels with hotkeys > > > On Tue, 27 May 2003 23:47:32 +1000, Derek Parnell > <ddparnell at bigpond.com> wrote: > > > > >I forgot to mention a new feature with win32lib. > > > >If you create a label control (LText, RText, CText) and place an '&' in its > >caption, then if the next field created is an input field, that input field > >has its own hotkey set to the label's hotkey. Thus ... > > > > lbl = create(RText, "&Customer:", Win, 5,10, 80, 25, 0) > > custname = create(EditBox, "", Win, 85, 10, 100, 25, 0) > > > >means that when the user presses Alt-C, the cursor jumps to the custname > >field. > > I've just upgraded to 0.58.09. Prior to this mod I had several dummy > fields eg Zsh=create(LText,"&Z",win,0,0,0,0,0) to capture the Alt-Z, > and an ongotfocus() routine to handle things manually. There isn't a > specific control it applies to (it is actually a bitmap of four > buttons, in a popup window, that I've carefully positioned over the > titlebar, and I handle the mouse clicks in that region explicitly). > I'm not surprised (and not upset either) they don't work no more. It's > not exactly a common programming technique > > I think what I need to do is remove the &Z from the definition of Zsh > and call registerHotKey(Zsh,"&Z"), right? > > A similar problem I have is: > "&Size" "" > <Slider> > where there is a text field after the &Size which later gets set with > "50%", "100%" etc. Which of the following would you recommend: > 1) a change to win32lib to cope with this (leave vs_PreviousControl as > is if it already contains a hotkey on a static field & there is no > hotkey on the current static field) > 2) just swap the define of my second field up. > 3) merge the two labels. > 4) something else > > Lastly, this might cause a problem for Judith's IDE. I don't use it so > I don't know if it puts the fields in the right order. I often do eg > create(text,x,10,10..) > create(combo,x,30,7,..) > to make them line up, so a strict sort on y then x co-ordinates would > not work, > > Pete > <shrug> > I don't want to think of how many ongotfocus(ltext) routines I'm going > to have to find and delete. > </shrug> > > > > TOPICA - Start your own email discussion group. FREE! > >
4. Re: win32lib labels with hotkeys
- Posted by Derek Parnell <ddparnell at bigpond.com> May 30, 2003
- 394 views
----- Original Message ----- From: "Pete Lomax" <petelomax at blueyonder.co.uk> To: "EUforum" <EUforum at topica.com> Subject: Re: win32lib labels with hotkeys > > > On Tue, 27 May 2003 23:47:32 +1000, Derek Parnell > <ddparnell at bigpond.com> wrote: > > > > >I forgot to mention a new feature with win32lib. > > > >If you create a label control (LText, RText, CText) and place an '&' in its > >caption, then if the next field created is an input field, that input field > >has its own hotkey set to the label's hotkey. Thus ... > > > > lbl = create(RText, "&Customer:", Win, 5,10, 80, 25, 0) > > custname = create(EditBox, "", Win, 85, 10, 100, 25, 0) > > > >means that when the user presses Alt-C, the cursor jumps to the custname > >field. > > I've just upgraded to 0.58.09. Prior to this mod I had several dummy > fields eg Zsh=create(LText,"&Z",win,0,0,0,0,0) to capture the Alt-Z, > and an ongotfocus() routine to handle things manually. There isn't a > specific control it applies to (it is actually a bitmap of four > buttons, in a popup window, that I've carefully positioned over the > titlebar, and I handle the mouse clicks in that region explicitly). > I'm not surprised (and not upset either) they don't work no more. It's > not exactly a common programming technique > > I think what I need to do is remove the &Z from the definition of Zsh > and call registerHotKey(Zsh,"&Z"), right? > > A similar problem I have is: > "&Size" "" > <Slider> > where there is a text field after the &Size which later gets set with > "50%", "100%" etc. Which of the following would you recommend: > 1) a change to win32lib to cope with this (leave vs_PreviousControl as > is if it already contains a hotkey on a static field & there is no > hotkey on the current static field) > 2) just swap the define of my second field up. > 3) merge the two labels. > 4) something else > > Lastly, this might cause a problem for Judith's IDE. I don't use it so > I don't know if it puts the fields in the right order. I often do eg > create(text,x,10,10..) > create(combo,x,30,7,..) > to make them line up, so a strict sort on y then x co-ordinates would > not work, > > Pete > <shrug> > I don't want to think of how many ongotfocus(ltext) routines I'm going > to have to find and delete. > </shrug> > Okay, I shouldn't have introduced this feature the way I did because it could (and in your case actually does) break existing code. I went and smacked my hand. So I've made the following changes which will be released on Sunday, but you might like to make them to your copy now. First find the lines ... sequence vs_PreviousControl -- static vs_PreviousControl = {} and add this routine after them ... integer vAutoFocusLabels vAutoFocusLabels = False ------------------------------------------------------------------------ --/topic Attributes --/func setAutoFocusLabels(integer NewValue) --/desc Sets whether or not a '&' in labels set focus to subsequent edit field. --/ret Returns INTEGER: The current value of the flag. --By default, this is set to False. Which means that any '&' in label captions -- is ignored as far as setting focus to a subsequently defined input field. /n -- If you set this to True then the '&' notation will cause focus to move to -- the next input field defined after the label. -- --Example: --/code -- integer lPrevFlag -- . . . -- -- Make labels focus on its input field. -- lPrevFlag = setAutoFocusLabels(True) -- -- The '&N' in the caption means that Alt-N will -- -- set focus to the next input field. -- lblX = create(LText, "&Name", Win, 5, 5, 40, 25, 0) -- fldX = create(Editbox, "", Win, 5, 30, 120, 25, 0) -- -- Set the flag back to whatever it was. -- lPrevFlag = setAutoFocusLabels(lPrevFlag) -- --/endcode --------------------------------------------------------------------------- -- global function setAutoFocusLabels(integer pNewValue) --------------------------------------------------------------------------- -- integer lOldValue lOldValue = vAutoFocusLabels vAutoFocusLabels = pNewValue return lOldValue end function Then find the lines a little bit further into the file ... if and_bits( WS_TABSTOP, classStyle[ pControl ] ) and length(vs_PreviousControl) != 0 then if classType[window_type[vs_PreviousControl[1]]] = STATIC then registerHotKey( id, vs_PreviousControl[2] ) else registerHotKey( id, caption ) end if elsif classType[pControl] != STATIC then registerHotKey( id, caption ) end if And add these three lines above them ... if vAutoFocusLabels = False then registerHotKey( id, caption ) else And then the corresponding 'endif' after the lines. This means that the new feature will have NO effect on existing programs, and if you want this new feature, you will specifically have to turn it on by entering ... VOID = setAutoFocusLabels(True) In fact, you can turn the feature on and off as required in your code. -- Derek.
5. Re: win32lib labels with hotkeys
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> May 30, 2003
- 398 views
On Sat, 31 May 2003 00:14:29 +1000, Derek Parnell <ddparnell at bigpond.com> wrote: >Okay, I shouldn't have introduced this feature the way I did because it >could (and in your case actually does) break existing code. I went and >smacked my hand. No need for that > >So I've made the following changes which will be released on Sunday, but= you >might like to make them to your copy now. Done, they work fine. > <snip> >This means that the new feature will have NO effect on existing = programs, >and if you want this new feature, you will specifically have to turn it = on >by entering ... > > VOID =3D setAutoFocusLabels(True) > >In fact, you can turn the feature on and off as required in your code. It's your decision, but I'm perfectly happy to add one line after my include win32lib.ew statements if it makes the library easier to use for everyone else. I'll definitely use the new feature in all new code Pete