Caps Lock indicator?

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
sotos
Posts: 28
Joined: Fri Feb 09, 2018 11:25 pm

Caps Lock indicator?

Post by sotos » Thu Dec 13, 2018 10:06 pm

Hello,

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

regards,
Sotiris

JamesDuignan
Posts: 81
Joined: Thu Nov 26, 2015 1:43 pm

Re: Caps Lock indicator?

Post by JamesDuignan » Mon Dec 17, 2018 11:29 am

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

sotos
Posts: 28
Joined: Fri Feb 09, 2018 11:25 pm

Re: Caps Lock indicator?

Post by sotos » Tue Dec 18, 2018 7:11 pm

thanks a lot!

Post Reply