AddDialogHandler OnEnter

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
liveitupmore
Junior Coder
Posts: 22
Joined: Wed Nov 16, 2005 3:58 am
Location: Gold Coast, Australia

AddDialogHandler OnEnter

Post by liveitupmore » Fri Dec 07, 2012 6:52 am

I'm trying to use the event handler to activate a subroutine when a user scans a barcode or fills a dialog box and presses enter.

Is the OnEnter event handler for such use ?

Here is a sample of the code

AddDialogHandler>Dialog1,Scan,OnEnter,DoEnter

Dialog>Dialog1
object Dialog1: TForm
Left = 251
Top = 104
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Open or Close Books'
ClientHeight = 216
ClientWidth = 439
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 86
Top = 48
Width = 68
Height = 13
Caption = 'Scan Barcode'
end
object Scan: TEdit
Left = 86
Top = 66
Width = 235
Height = 21
TabOrder = 8
end
object MSButton1: tMSButton
Left = 86
Top = 134
Width = 75
Height = 25
Caption = 'OK'
ModalResult = 1
TabOrder = 9
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 227
Top = 134
Width = 75
Height = 25
Caption = 'Finished'
ModalResult = 2
TabOrder = 10
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1

SRT>DoEnter
GetDialogProperty>Dialog1,Scan,Text,varScan
MessageModal>Entered barcode is %varScan%
END>DoEnter

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Dec 07, 2012 9:43 am

You would need the AddDialogHandler AFTER The dialog block because at the moment the dialog does not even exist when you call it so the script would have no idea what to do with it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

liveitupmore
Junior Coder
Posts: 22
Joined: Wed Nov 16, 2005 3:58 am
Location: Gold Coast, Australia

Post by liveitupmore » Sat Dec 08, 2012 1:49 am

My humble apologies, I cut and pasted the code fragments and in doing so put them in the wrong order.

I have since checked and it still doesn't work.

I did however read your email today about custom event triggers and saw a related post on keypress for eventhandlers. I have tried this method and it works like a charm.

One question though is OnEnter supposed to trigger when you press the Enter key ??

Alistair

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Dec 08, 2012 6:19 am

is OnEnter supposed to trigger when you press the Enter key ??
It could if the dialog is set up that way but that's not the intent. The intent is that it triggers when the object receives focus.

liveitupmore
Junior Coder
Posts: 22
Joined: Wed Nov 16, 2005 3:58 am
Location: Gold Coast, Australia

Post by liveitupmore » Sun Dec 09, 2012 11:49 am

Many thanks

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts