Hi,
It looks to me that TButtons and FlatButtons etc do not have a way of being actioned by a keyboard character, probably?
If I want the TButtons to be in a TToolbar and I would like the buttons to be actioned by a keyboard character also .... Is a parallel set of XA_SetKey() functions the best way of trying to simulate keypress actions in a TToolbar of TButtons?
Maybe I can subclass TToolbar and add some 'Action key' info to TButton:cargo .... something like that?
I still believe that keypresses can be a valuable part of very productive applications.
Any guidance would be appreciated.
Chris Gillard
In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
TButtons or similar with active keys?
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: TButtons or similar with active keys?
Some progress,
If I set the button text to "&View" or "&Add" .... I get an underline on the letter after the & and it becomes an action key with ALT+V etc.
I now remember the '&' technique from many years ago.
That's a start of what I want.
In an ideal world I would be able to colour the action letter in red also ... but that's maybe too much to ask?
Maybe I can get to the canvas and write my own text?
Chris
If I set the button text to "&View" or "&Add" .... I get an underline on the letter after the & and it becomes an action key with ALT+V etc.
I now remember the '&' technique from many years ago.
That's a start of what I want.
In an ideal world I would be able to colour the action letter in red also ... but that's maybe too much to ask?
Maybe I can get to the canvas and write my own text?
Chris
- ignacio
- Site Admin
- Mensajes: 9253
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Re: TButtons or similar with active keys?
Hello,
I suggest you simply trap the keyboard events at the form level. To fire the buttons event manually just call its click event.
Regards
I suggest you simply trap the keyboard events at the form level. To fire the buttons event manually just call its click event.
Regards
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: TButtons or similar with active keys?
Hi Ignacio,
I will do as you suggest and trap the keyboard events from the form and fire the button events in code.
Thank you for the suggestion.
Chris
I will do as you suggest and trap the keyboard events from the form and fire the button events in code.
Thank you for the suggestion.
Chris
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: TButtons or similar with active keys?
Hmm trapping the onChar event of the form is not going to be ideal for this what I have in mind.
I am writing a Class, inherited from TPanel, that you will call from code, and this class will contain several buttons that will have their own onClick events but I need some way of calling those same events with keyboard characters.
It's a little bit like a TDbNavigator with its buttons being able to also respond to keyboard input by just placing the control on the form ... no extra code in the Form:OnChar event.
Ideally I dont want to do anything in the Form, I would like my class to be able to listen & respond to the characters that are being detected by the low level windows keyboard event handling.
I think I want to listen to the Windows keyboard messages and if my Class is in 'focus' I need to detect any keyboard characters.
I need my class to listen for characters, not be told what to do by onChar of the form.
Something like that. You must do this sort of clever stuff!
Chris
I am writing a Class, inherited from TPanel, that you will call from code, and this class will contain several buttons that will have their own onClick events but I need some way of calling those same events with keyboard characters.
It's a little bit like a TDbNavigator with its buttons being able to also respond to keyboard input by just placing the control on the form ... no extra code in the Form:OnChar event.
Ideally I dont want to do anything in the Form, I would like my class to be able to listen & respond to the characters that are being detected by the low level windows keyboard event handling.
I think I want to listen to the Windows keyboard messages and if my Class is in 'focus' I need to detect any keyboard characters.
I need my class to listen for characters, not be told what to do by onChar of the form.
Something like that. You must do this sort of clever stuff!
Chris
Re: TButtons or similar with active keys?
Chris,
if you're writing your own class, inherited from any Xailer's control or from TControl itself, the easiest way to trap key strokes is by overwriting the WMKeyDown() method. Even if this control is a "container control", which can hold other controls on top of it, it will always be called when the key pressed is not processed and/or "stopped" by the child control which has focus. That is, if a child control process a key stroke and returns 0, its parent doesn't see that key stroke, but any other case it does.
So, try to overwrite the WMKeyDown() method to process any key you want, and don't forget to end it with ::Super:WMKeyDown( nKey, nFlags, hWnd )
BTW, the same applies to WMChar() also.
if you're writing your own class, inherited from any Xailer's control or from TControl itself, the easiest way to trap key strokes is by overwriting the WMKeyDown() method. Even if this control is a "container control", which can hold other controls on top of it, it will always be called when the key pressed is not processed and/or "stopped" by the child control which has focus. That is, if a child control process a key stroke and returns 0, its parent doesn't see that key stroke, but any other case it does.
So, try to overwrite the WMKeyDown() method to process any key you want, and don't forget to end it with ::Super:WMKeyDown( nKey, nFlags, hWnd )
BTW, the same applies to WMChar() also.
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: TButtons or similar with active keys?
Jose,
Thank you for that idea. I think that is what I need.
I am trying write something Like a TDbNavigator with number of buttons but also with keyboard action.
Overriding WMKeyDown() or WMChar() seems like the way to go.
Thank you very much.
Chris
Thank you for that idea. I think that is what I need.
I am trying write something Like a TDbNavigator with number of buttons but also with keyboard action.
Overriding WMKeyDown() or WMChar() seems like the way to go.
Thank you very much.
Chris