Set function key to a Value
Moderator: Rathinagiri
Set function key to a Value
Hello again,
I am trying to set function keys to values like I did in Clipper.
Clipper command Set function 22 to '123'
When ever I hit ctrl+function 2 in a inputbox or textbox it would type 123 in the box.
I can not get this to work in HMG, I know there must be a way to do it.
Thanks in advance........... Franco
I am trying to set function keys to values like I did in Clipper.
Clipper command Set function 22 to '123'
When ever I hit ctrl+function 2 in a inputbox or textbox it would type 123 in the box.
I can not get this to work in HMG, I know there must be a way to do it.
Thanks in advance........... Franco
All The Best,
Franco
Canada
Franco
Canada
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Set function key to a Value
Franco,
you can use:
ON KEY F1 ACTION {somefunction() }
Serge
you can use:
ON KEY F1 ACTION {somefunction() }
Serge
There's nothing you can do that can't be done...
Re: Set function key to a Value
Serge
how could I say
ON KEY F22 KEYBOARD '123'
fRANCO
how could I say
ON KEY F22 KEYBOARD '123'
fRANCO
All The Best,
Franco
Canada
Franco
Canada
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Set function key to a Value
Franco,
Try this:
Try this:
Code: Select all
DEFINE WINDOW Form_1
...
ON KEY F1 ACTION somefunction()
...
END WINDOW
FUNCTION Somefunction()
keyboard '123'
RETURN
There's nothing you can do that can't be done...
Re: Set function key to a Value
Franco
If you use the GUI the command "keyboard" does not work.
When i assume the window (form) is named Form_1, you can use this:
Theo
If you use the GUI the command "keyboard" does not work.
When i assume the window (form) is named Form_1, you can use this:
Code: Select all
ON KEY F1 OF Form_1 ACTION Somefunction()
FUNCTION Somefunction()
_Pushkey(VK_1) // Press "1"
_Pushkey(VK_2) // Press "2"
_Pushkey(VK_3) // Press "3"
RETURN
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Set function key to a Value
Hi Franco,
Alternatively, you could do this:
Alternatively, you could do this:
Code: Select all
ON KEY F1 OF Form_1 ACTION Somefunction()
FUNCTION Somefunction()
cFocusedControl := GetProperty( 'Form_1' , 'FocusedControl' )
SetProperty( 'Form_1' , FocusedControl , 'Value' , '123' )
RETURN
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Set function key to a Value
Hi Franco,
Alternatively, you could do this:
Or:
Alternatively, you could do this:
Code: Select all
ON KEY F1 OF Form_1 ACTION Somefunction()
FUNCTION Somefunction()
cFocusedControl := GetProperty( 'Form_1' , 'FocusedControl' )
SetProperty( 'Form_1' , cFocusedControl , 'Value' , '123' )
RETURN
Code: Select all
ON KEY F1 OF Form_1 ACTION SetProperty( 'Form_1' , GetProperty( 'Form_1' , 'FocusedControl' ) , 'Value' , '123' )
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: Set function key to a Value
Hi Franco,
A little addition to the very nice code of Roberto. To preserve errors when pressing F1 check if the focussed control is an EDITBOX.
In addition, to be perfect, you also have to check if the "EDITBOX" is ReadOnly.
Theo
A little addition to the very nice code of Roberto. To preserve errors when pressing F1 check if the focussed control is an EDITBOX.
Code: Select all
FUNCTION Somefunction()
cFocusedControl := GetProperty( 'Form_1' , 'FocusedControl' )
IF GetControlType( cFocusedControl , "Form_1") == "EDITBOX"
SetProperty( 'Form_1' , cFocusedControl , 'Value' , '123' )
ENDIF
RETURN
Theo
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Set function key to a Value
Theo:
AFAIR, the values returned by GetControlType() are the following for text inputs:
For TextBox:
"NUMTEXT", "TEXT","MASKEDTEXT"
For EditBox:
"EDIT" (not 'EDITBOX' )
So, The correct code should be:
AFAIR, the values returned by GetControlType() are the following for text inputs:
For TextBox:
"NUMTEXT", "TEXT","MASKEDTEXT"
For EditBox:
"EDIT" (not 'EDITBOX' )
So, The correct code should be:
Code: Select all
FUNCTION Somefunction()
cFocusedControl := GetProperty( 'Form_1' , 'FocusedControl' )
IF GetControlType( cFocusedControl , "Form_1") == "EDIT" .Or. GetControlType( cFocusedControl , "Form_1") == "TEXT"
SetProperty( 'Form_1' , cFocusedControl , 'Value' , '123' )
ENDIF
RETURN
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: Set function key to a Value
Roberto,
You are right, thanks for improving the demo !
Franco can go on now
Theo
You are right, thanks for improving the demo !
Franco can go on now
Theo