Page 1 of 1

Don't want ENTER to push button

Posted: Tue Jan 09, 2007 2:05 pm
by Ollie
I have a dialog with a bunch of GETS, I want the user to press Enter through the fields as he enters them.

When I press enter, it presses the 'Save' button. How can I make it not do that, forcing the user to Click "Save" when he is ready.

Posted: Tue Jan 09, 2007 2:12 pm
by areang
Mr. Ollie

when user clicked "Save" button then action for MySave()

function MySave()
if MsgYesNo("Are you sure ?")
/*
put here for save your variable
*/
endif
return nil

Regards
Areang

Posted: Tue Jan 09, 2007 3:23 pm
by Gale FORd
It sounds like your "Save" button has been set to default. If you remove the default setting then the enter key will take you to the next field instead of pressing the default button.

Posted: Tue Jan 09, 2007 3:47 pm
by Ollie
It hasn't been set to default. As far as I know. (There is no DEFAULT clause in the button definition How do I set default off?

Code: Select all

   
   REDEFINE BTNBMP oBtn_Save ID IDOK of Dlg_SUB PROMPT "Save" TOP RESOURCE "save" ACTION ( Update_dbmain(), Dlg_SUB:END() ) TOOLTIP "Save"
   REDEFINE BTNBMP oBtn_Cancel ID IDCANCEL of Dlg_SUB PROMPT "Cancel" TOP RESOURCE "cancel" ACTION ( oDBF_MAIN:Load(), Dlg_Dbmain:Update(),  Dlg_SUB:END() ) TOOLTIP "Cancel"
   

Posted: Tue Jan 09, 2007 4:35 pm
by Gale FORd
Check the resource. In a resource editor or in the .rc

CONTROL "OK", 1, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 4, 49, 40, 14

change BS_DEFPUSHBUTTON to BS_PUSHBUTTON

Posted: Tue Jan 09, 2007 7:30 pm
by James Bott
Ollie,

>I have a dialog with a bunch of GETS, I want the user to press Enter through the fields as he enters them.

This is DOS behavior not Windows behavoir. Most users will expect the Tab key to move between fields, and the Enter key to push the default button. Having the Enter key work this way prevents them from having to use the mouse to press the button.

James

Posted: Tue Jan 09, 2007 9:42 pm
by Ollie
Ok, I accept that. Is there a way for the TAB key to jump to the next TAB/Folder or does one need to use the mouse to change TABS.

Posted: Tue Jan 09, 2007 9:57 pm
by James Bott
Ollie,

>Is there a way for the TAB key to jump to the next TAB/Folder or does one need to use the mouse to change TABS.

Well, you can't have the Tab key jump to the next control AND jump to the next folder. If you define a hot-key in the folder name (e.g. "&Orders" ) then the user can use Alt-O to jump to the next folder.

I think you would get a lot ouf of reading the book, "About Face 2.0, The Essentials of Interaction Design," by Alan Cooper and Robert M. Reimann. This is a teriffic book about Windows application interface design. You can find out more about it on my website on this page:

http://ourworld.compuserve.com/homepage ... rogram.htm

James [/quote]

Posted: Wed Jan 10, 2007 8:48 am
by Detlef Hoefner
Ollie wrote:It hasn't been set to default. As far as I know. (There is no DEFAULT clause in the button definition How do I set default off?

Code: Select all

   
   REDEFINE BTNBMP oBtn_Save ID IDOK of Dlg_SUB PROMPT "Save" TOP RESOURCE "save" ACTION ( Update_dbmain(), Dlg_SUB:END() ) TOOLTIP "Save"
   REDEFINE BTNBMP oBtn_Cancel ID IDCANCEL of Dlg_SUB PROMPT "Cancel" TOP RESOURCE "cancel" ACTION ( oDBF_MAIN:Load(), Dlg_Dbmain:Update(),  Dlg_SUB:END() ) TOOLTIP "Cancel"
   
Ollie,

a redefine-ID of 1 or 2 ( IDOK or IDCANCEL ) will give your button the default behaviour when pressing the enter key.

Maybe that helps,
Detlef

Posted: Wed Jan 10, 2007 12:41 pm
by Ollie
Detlef,

I could set ID to 1, and 2, but set to 10 and 20, and, I don't know why, but it worked!

Thanks

Posted: Wed Jan 10, 2007 3:26 pm
by Gale FORd
I forgot about id 1. I quit using that id so long ago.

Posted: Thu Jan 11, 2007 6:49 am
by Ollie
Sorry - typo- I meant to say I could NOT set the ID to 1. Using Pelles C - it reverts to 10 all the time. Anyway it all worked - thanks everyone.