Which Key Has Been Pressed?
Moderators: JRL, Dorian (MJT support)
Which Key Has Been Pressed?
Given AddDialogHandler>Dialog1,MSComboBox1,OnKeypress,DoCloseDialog, how to detect which key was presed in SRT>DoCloseDialog?
In the MSComboBox1, if the user presses ENTER, his acceptance is assumed.
If the user press ESC, his rejection is assumed.
In the MSComboBox1, if the user presses ENTER, his acceptance is assumed.
If the user press ESC, his rejection is assumed.
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
Try this...
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 614
Top = 225
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 212
ClientWidth = 431
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSComboBox1: tMSComboBox
Left = 17
Top = 31
Width = 145
Height = 21
ItemHeight = 13
TabOrder = 8
Items.Strings = (
'A'
'B')
ListText = 'A'#13#10'B'#13#10
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSComboBox1,OnSelect,GetRslt
Show>Dialog1,r
SRT>GetRslt
GetDialogProperty>Dialog1,MSComboBox1,Text,rslt
MDL>rslt
END>GetRslt
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
In your OnKeyPress subroutine look at the value of SRTNAME_KEY. E.g.:
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 750
Top = 371
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 223
ClientWidth = 439
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSComboBox1: tMSComboBox
Left = 60
Top = 26
Width = 145
Height = 21
ItemHeight = 13
TabOrder = 8
Text = 'MSComboBox1'
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSComboBox1,OnKeyPress,DoKeyPress
Show>Dialog1,r
SRT>DoKeyPress
MessageModal>Key pressed code was %DoKeyPress_Key%
END>DoKeyPress
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Just been made aware that this feature of parameters passed into the subroutine by the event is not documented, though there is a sample script that comes with the software which shows it in action (Dialogs - MouseOver).
There's no list anywhere, so - right now - to find out what parameters, if any, are passed in by an event, stick a breakpoint at the top of the subroutine and then look at the watch list to see what is available. I'll try and find some time to write a blog post on this soon.
There's no list anywhere, so - right now - to find out what parameters, if any, are passed in by an event, stick a breakpoint at the top of the subroutine and then look at the watch list to see what is available. I'll try and find some time to write a blog post on this soon.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
This is a great find... looking forward to your blog post on this.mtettmar wrote:There's no list anywhere, so - right now - to find out what parameters, if any, are passed in by an event, stick a breakpoint at the top of the subroutine and then look at the watch list to see what is available. I'll try and find some time to write a blog post on this soon.
Thanks and take care
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Just in case you haven't already seen it I put together a short video and blog post on this topic here:
http://www.mjtnet.com/blog/2011/02/08/u ... arameters/
http://www.mjtnet.com/blog/2011/02/08/u ... arameters/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi Marcus,
Yes, I watched it last night... the video was perfect for showing what is happening and how to use the debugger to see what is going on... thanks for making that available.
Please also consider, when time permits and maybe with the next maintenance release, adding a new Topic to the Help File that has a complete list of which parameters, if any, are passed in on various events.
There is a lot of power here... and seeing the full list will help us explore more of it.
Thanks and take care
Yes, I watched it last night... the video was perfect for showing what is happening and how to use the debugger to see what is going on... thanks for making that available.
Please also consider, when time permits and maybe with the next maintenance release, adding a new Topic to the Help File that has a complete list of which parameters, if any, are passed in on various events.
There is a lot of power here... and seeing the full list will help us explore more of it.
Thanks and take care
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Is anyone volunteering to compile such a list? I don't have one. It would take some time to try all permutations of all objects and all event handlers to find all parameters. Anyone offering?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Marcus,
Thanks for taking time to produce http://www.mjtnet.com/blog/2011/02/08/u ... arameters/. It's very helpful.
Thanks for taking time to produce http://www.mjtnet.com/blog/2011/02/08/u ... arameters/. It's very helpful.