Is it possible, in a Window, to acknowledge the Enter key.
This is what I am doing:
CONTROL main,@Button,"Clear",80,340,60,25,0,CLRBUTTON2
CASE CLRBUTTON1 'Save
SELECT @NOTIFYCODE
CASE 0
Save()
SetFocus main,EDIT2
CASE @ENENTERKEY
Save()
SetFocus main,EDIT2
ENDSELECT
It does not seem to work.
Thanks for any Help...
Bill
@ENENTERKEY is a notification message that an edit control sends to the parent window (hince EN - edit notification)
as far as I know a button doesn't use that message.
Totally guessing at what you are really trying to accomplish but think this is more in line with what you should be doing.
CONTROL main,@Button,"Clear",80,340,60,25,0,CLRBUTTON1
CONTROL main,@edit,"blah",80,340,60,25,0,EDIT2
SETCONTROLNOTIFY main,EDIT2,FALSE,TRUE
CASE CLRBUTTON1 'Save
SELECT @NOTIFYCODE
CASE 0
Save()
SetFocus main,EDIT2
ENDSELECT
CASE EDIT2
SELECT @NOTIFYCODE
CASE @ENENTERKEY
Save()
SetFocus main,EDIT2
ENDSELECT
I was hoping that when focus was on my SAVE button, that you could press ENTER and it would act as if I was clicking on it. That is what I am trying to do. I was hoping it was possible. Would also like space bar or tab to notifiy me so I can have it set focus to the next button, which would be the CLEAR button.
Thanks,
Bill
but in the example you gave you are switching focus back to the edit control each time which sort of messes things up because the space is a valid text character in an edit control
here's some code for you to play with.
window main
openconsole
OPENWINDOW main,0,0,300,400,0,0,"Caption",&handler
CONTROL main,@EDIT,"Press Enter or TAB",83,39,124,27,0x50800000|@CTEDITAUTOH,5
CONTROL main,@sysButton,"Clear",80,100,60,25,@tabstop,10
SETFONT main,"Ariel",9,400,0,5
SETCONTROLNOTIFY(main,5,1,1)
SETCONTROLNOTIFY(main,10,1,1)
SetFocus main,10
WAITUNTIL main=0
closeconsole
END
SUB handler(),int
SELECT @MESSAGE
case @IDCHAR
select @wparam
case 9 'tab
case& 13 'enter
case& 32 ' spacebar
SetFocus main,5
endselect
?@message,@wparam
CASE @IDCONTROL
select @controlid
CASE 10 'Save
?@message
SELECT @NOTIFYCODE
CASE 0
?"button pressed"
'MESSAGEBOX main,GetControlText(main,5),"Button Pressed!"
SetFocus main,5
CASE @ENENTERKEY
?"button enter key"
'MESSAGEBOX main,GetControlText(main,5),"Button Enter Pressed!"
SetFocus main,5
CASE @ENTABKEY
?"button tab key"
'MESSAGEBOX main,"Tab key pressed","Info"
SetFocus main,5
ENDSELECT
case 5
SELECT @NOTIFYCODE
CASE @ENENTERKEY
?"edit enter key"
'MESSAGEBOX main,GetControlText(main,5),"Enter Pressed!"
SetFocus main,5
CASE @ENTABKEY
?"edit tab key"
'MESSAGEBOX main,"Tab key pressed","Info"
SetFocus main,5
ENDSELECT
endselect
CASE @IDCREATE
CENTERWINDOW main
CASE @IDCLOSEWINDOW
CLOSEWINDOW main
ENDSELECT
RETURN 0
endsub
Does it have to use a @SysButton to allow the Enter Key to work? If I must use a @SysButton, why does the
SETCONTROLCOLOR main,CLRBUTTON1,RGB(255,255,0),RGB(0,0,255)
NOT change the color of the button?
Thanks,
Bill
Quote from: billhsln on December 24, 2012, 09:02:50 AM
Does it have to use a @SysButton to allow the Enter Key to work? If I must use a @SysButton, why does the
SETCONTROLCOLOR main,CLRBUTTON1,RGB(255,255,0),RGB(0,0,255)
NOT change the color of the button?
Thanks,
Bill
Not sure you have use a @sysbutton (that was part of MY playing and why I told you to play with it.)
From the Help file for SETCONTROLCOLOR:
Quote@SYSBUTTON controls do not support color changes.