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.

Trying to detect ALT + key in Form ....

Xailer professional forum in English
Responder
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Trying to detect ALT + key in Form ....

Mensaje por ChrisGillard »

Hi,

Am exploring how to make Buttons or Prompts respond to mouse clicks and key presses including ALT+Key combinations .... maybe enhanced TButtons or maybe TLabel/TLabelEx made into buttons.

I have looked at how TButton uses the & to give it an Action Key and how this adds the Key to an array ::aShortcut in TForm.

I would like to Add ALT+key combinations to be Action keys in the form.

I could have a ::aAltKeys in an inherited TForm and Add and Remove oControls like in ::aShortcut .... this would be quite elegant and 'correct'.

Then I need to detect the ALT+key and scan my ::aAltKeys.

Problem here is I have not found a way to detect the ALT+Keys at form level usinf say FormKeyDown() or FormChar() ..... is there a way I can use?

or I could use XA_SetKey() again adding and deleting ALT+keys as necessary ..... no very elegant and not very 'correct' .... but maybe my best chance?

Another question .... do we have the source to XA_SetKey(), I can't find it and it might be useful to me?

Any thoughts would be appreciated.

Thanks

Chris
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5705
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Re: Trying to detect ALT + key in Form ....

Mensaje por jfgimenez »

Chris,

there is no OnSysKeyDown event in the form, but you may override the method WMSysKeyDown:

Código: Seleccionar todo

METHOD WMSysKeyDown( nKey, nFlags ) CLASS TForm1

   IF nKey == VK_F2   // Alt+F2
   	// Do something...
   ENDIF
   
RETURN Nil
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Re: Trying to detect ALT + key in Form ....

Mensaje por ChrisGillard »

Jose,

Thank you for the reply and suggestion.

I probably want to detect ALT + anykey and then scan an array of Keys & Action pairs to execute the action.

I will do some testing.

Have a good weekend, thanks again.

Chris
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Re: Trying to detect ALT + key in Form ....

Mensaje por ChrisGillard »

Jose,

I have had ago, below is my code and what I see using LogDisplay()

Do you expect to get the Alt and the other key as 2 actions? I'm sure I can cope if that's the way it is.

Alt A and Alt B give sensible nKey for the A & B, always upper case but that's fine.

Alt F2 gives me a 'q' for a character, lower case. Other Al Fkeys give different ascii so could easily be detected and converted to F1, F2, F3 etc.

I think its workable, is this how it should be?

Definitely progress.

Thank you.

Chris
Adjuntos
result.png
result.png (22.6 KiB) Visto 3641 veces
code.png
code.png (3.23 KiB) Visto 3641 veces
Responder