Don't want ENTER to push button

Post Reply
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Don't want ENTER to push button

Post 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.
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
areang
Posts: 128
Joined: Mon Jul 31, 2006 3:23 pm

Post 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
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Post 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.
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Post 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"
   
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Post 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.
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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]
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post 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
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Post 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
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Post by Gale FORd »

I forgot about id 1. I quit using that id so long ago.
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Post 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.
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Post Reply