Page 1 of 1

Caps Lock indicator?

Posted: Thu Dec 13, 2018 10:06 pm
by sotos
Hello,

Is there any way to find out whether the caps lock indicator is on?
This is useful for login screens.

regards,
Sotiris

Re: Caps Lock indicator?

Posted: Mon Dec 17, 2018 11:29 am
by JamesDuignan
Hi Soritos,

The easiest method to do this would be putting some simple logic into the keypress event of a the input field.

The checks are something like
1. If shift is down and the character is lowercase caps lock is on.
2. If shift isn't down and character is uppercase caps lock is on.
3. If shift is down and the character is uppercase caps lock is off.
4. If shift isn't down and character is lowercase caps lock is off.

Something along the lines of:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB)

Define_Com Class(#PRIM_MD.Edit) Name(#Edit) Caption('Caption') Displayposition(1) Left(80) Parent(#COM_OWNER) Tabposition(1) Top(40) Width(441) Passwordchar('*')

Evtroutine Handling(#Edit.KeyPress) Isshiftdown(#ShiftDown) Char(#Char)

If (#Char <> *BLANKS)

If ((#ShiftDOWN) *And (#Char.LowerCase = #Char) *Or (*Not #ShiftDOWN) *And (#Char.UpperCase = #Char))

#Edit.HelperColor := 'Red'

#Edit.HelperText := 'Caps lock is on'

Endif

If ((#ShiftDOWN) *And (#Char.UpperCase = #Char) *Or (*Not #ShiftDOWN) *And (#Char.LowerCase = #Char))

#Edit.HelperColor := 'Green'

#Edit.HelperText := 'Caps lock is off'

Endif

Endif

Endroutine

End_Com
Regards,
James

Re: Caps Lock indicator?

Posted: Tue Dec 18, 2018 7:11 pm
by sotos
thanks a lot!