Hi
Just swapped to IWBasic after many years with PB and have run into a problem straight away.
Why doesn't the following designer generated code respond to the 'Enter Key'
Michael
Complete code:
'@@INCLUDE - Designer generated, do not edit
$MAIN
$INCLUDE "EnterKey.inc"
$INCLUDE "globals.iwb"
'@@
OpenMainWindow()
ProcessAll()
END
SUB OpenMainWindow()
'@@CREATE_main
OPENWINDOW main,0,0,757,393,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU,0,"Form2",&main_handler
'@@
'@@ICON
'@@
'@@CTRL_INIT_main
CONTROL main,@EDIT,"Edit 1",255,95,151,25,@CTEDITAUTOH,main_EDIT1
'@@
'@@INIT_main
SETFONT main,"MS Sans Serif",8,400,0
SETWINDOWCOLOR main, RGB(255,255,255)
FRONTPEN main, RGB(0,0,0)
SETFONT main,"MS Sans Serif",8,400,0,main_EDIT1
SETCONTROLCOLOR main,main_EDIT1,RGB(0,0,0),RGB(255,255,255)
CENTERWINDOW main
'@@
'@@INITFORMS
'@@
'@@INITMENU
'@@
'@@MENUHANDLERS
'@@
'@@TOOLBAR
'@@
'@@TOOLBARHANDLERS
'@@
'@@HANDLERS_main
ONMESSAGE main,@IDCLOSEWINDOW,&OnMainClose
ONCONTROL main,main_EDIT1,@ENENTERKEY,&OnEnterKey_main_EDIT1
ONCONTROL main,main_EDIT1,@ENCHANGE,&OnChange_main_EDIT1
'@@
ENDSUB
SUB main_handler(),INT
SELECT @MESSAGE
CASE @IDSIZE
'@@TBSIZE
'@@
ENDSELECT
RETURN FALSE
ENDSUB
SUB ProcessAll()
WAITUNTIL ISWINDOWCLOSED(main)
ENDSUB
SUB OnMainClose(),INT
'@@ICONCLOSE
'@@
'@@TOOLBARCLOSE
'@@
CLOSEWINDOW main
RETURN FALSE
ENDSUB
'@@TABCONTROL
'@@
SUB OnEnterKey_main_EDIT1(),INT
'TODO: write handler code
Messagebox (0, "Enter key", "Testing", @MB_OK|@MB_ICONINFORMATION)
RETURN FALSE
ENDSUB
SUB OnChange_main_EDIT1(),INT
'TODO: write handler code
Messagebox (0, "Character input", "Testing", @MB_OK|@MB_ICONINFORMATION)
RETURN FALSE
ENDSUB
From the help file section
Windows programming > Controls > Using Edit ControlsNotification messages@ENENTERKEY
The user has pressed the ENTER key while the control has input focus. Only sent if enabled by the SETCONTROLNOTIFY command.Your solution is to add the following line
QuoteSETCONTROLNOTIFY(main,main_EDIT1,0,1)
in the location shown below.
'@@INIT_main
SETFONT main,"MS Sans Serif",8,400,0
SETWINDOWCOLOR main, RGB(255,255,255)
FRONTPEN main, RGB(0,0,0)
SETFONT main,"MS Sans Serif",8,400,0,main_EDIT1
SETCONTROLCOLOR main,main_EDIT1,RGB(0,0,0),RGB(255,255,255)
CENTERWINDOW main
'@@
SETCONTROLNOTIFY(main,main_EDIT1,0,1) '<<================
'@@INITFORMS
Note: My initial thought is that this line of missing code should have been added automatically when you made the selection in the Message Handler dialog.
This also applies to the TabKey.
I need to study things a bit so as to make sure by adding the code automatically I'm not going to create another problem.
Thanks for reporting the issue and furnishing the code for me to check.
Thanks Larry, all is well now.
Michael
Automatically adding the code mentioned above when the parent is a WINDOW is no problem.
However, when the parent is a DIALOG the enter and tab keys have a different function.
If the code is auto added in both WINDOWS and DIALOGS then in order to make dialogs work "normally" the user would have to make an additional manual entry to override the corresponding automatic entry.
I feel in the long run it will be less confusing to leave things as they are.
For reference see:
http://www.ionicwind.com/forums/index.php?topic=5304.msg39714#msg39714
http://www.ionicwind.com/forums/index.php?topic=1585.msg14640#msg14640
http://www.ionicwind.com/forums/index.php?topic=2998.msg24759#msg24759