Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » OK and Cancel Layout
OK and Cancel Layout [message #60742] Thu, 22 August 2024 01:55 Go to next message
sduensin is currently offline  sduensin
Messages: 8
Registered: August 2024
Location: Smithton, IL, USA, Earth
Promising Member
I've just started using U++ and so far am impressed. However, I've run into some confusion with laying out dialogs that contain "OK" and "Cancel" buttons.

The tutorial says to name two buttons - one "ok" and one "cancel" - and then call CtrlLayoutOKCancel. I did this, and it works. But...

Can you not control the order of the buttons? On my form, I have "cancel" and then "ok". When it displays at runtime, the "ok" button is first! I can deal with this, except when using PromptOKCancel, they're the other way around!

How can I have consistent buttons?
Re: OK and Cancel Layout [message #60743 is a reply to message #60742] Fri, 23 August 2024 07:43 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3432
Registered: August 2008
Senior Veteran
Hi sduensin

Please upload your sample code and we will show you how easy is doing what you want.


Best regards
Iñaki
Re: OK and Cancel Layout [message #60746 is a reply to message #60743] Fri, 23 August 2024 23:33 Go to previous messageGo to next message
sduensin is currently offline  sduensin
Messages: 8
Registered: August 2024
Location: Smithton, IL, USA, Earth
Promising Member
Thanks! I've attached my current code. When you run it, if you pull down "Settings" and go to the database setup, you'll see the buttons are the reverse from how they are displayed if you pull down "File" and select exit.

Also, is there a way to change dialog titles? Right now I'm calling the app "Store Manager" but PromptOK() and friends display "StoreManager" (no space) in the title bar.

I appreciate the help!
Re: OK and Cancel Layout [message #60747 is a reply to message #60746] Sun, 25 August 2024 20:26 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3432
Registered: August 2008
Senior Veteran
Hi sduensin

For some reason there are two application names, one defined in App.cpp (static char sAppName[256]) and other in Ctrl.cpp (String Ctrl::appname). To be sure, I will use both, so I would leave main like this:
GUI_APP_MAIN {
	StoreManager app;
	app.SetAppName(APP_NAME);
	SetAppName(APP_NAME);
	app.Run();
}

In addition I cannot see the problem with the buttons; they appear as they are designed. Look at this picture:

index.php?t=getfile&id=6955&private=0


Best regards
Iñaki
Re: OK and Cancel Layout [message #60748 is a reply to message #60747] Mon, 26 August 2024 03:00 Go to previous messageGo to next message
sduensin is currently offline  sduensin
Messages: 8
Registered: August 2024
Location: Smithton, IL, USA, Earth
Promising Member
Must be a Linux/GTK issue...

index.php?t=getfile&id=6956&private=0
Re: OK and Cancel Layout [message #60749 is a reply to message #60748] Mon, 26 August 2024 09:34 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3432
Registered: August 2008
Senior Veteran
Oh yes, probably that is enforced by GTK.

index.php?t=getfile&id=6957&private=0

I advise you to simply replace the CtrlLayoutOKCancel() by a CtrlLayout(), and handling the OK and Cancel buttons.


Best regards
Iñaki
Re: OK and Cancel Layout [message #60750 is a reply to message #60747] Tue, 27 August 2024 00:16 Go to previous messageGo to next message
sduensin is currently offline  sduensin
Messages: 8
Registered: August 2024
Location: Smithton, IL, USA, Earth
Promising Member
[quote title=koldo wrote on Sun, 25 August 2024 13:26]
For some reason there are two application names, one defined in App.cpp (static char sAppName[256]) and other in Ctrl.cpp (String Ctrl::appname). To be sure, I will use both, so I would leave main like this:
GUI_APP_MAIN {
	StoreManager app;
	app.SetAppName(APP_NAME);
	SetAppName(APP_NAME);
	app.Run();
}


That fixed it! Thanks!
Re: OK and Cancel Layout [message #60752 is a reply to message #60750] Tue, 27 August 2024 08:15 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3432
Registered: August 2008
Senior Veteran
You are welcome!

Best regards
Iñaki
Re: OK and Cancel Layout [message #60756 is a reply to message #60742] Thu, 29 August 2024 00:31 Go to previous messageGo to next message
sduensin is currently offline  sduensin
Messages: 8
Registered: August 2024
Location: Smithton, IL, USA, Earth
Promising Member
Doh! I just noticed that this code, while it does fix the config dir name and app name, it does not fix where the log is written. Oh well.
Re: OK and Cancel Layout [message #60759 is a reply to message #60748] Mon, 02 September 2024 00:24 Go to previous message
mirek is currently offline  mirek
Messages: 14255
Registered: November 2005
Ultimate Member
sduensin wrote on Mon, 26 August 2024 03:00
Must be a Linux/GTK issue...

index.php?t=getfile&id=6956&private=0


There is very special and sort of nasty code that swaps OK and Cancel buttons automatically in gtk and macos because that is how those platform have these buttons usually. I mean, you desing as "in windows" and it then gets swapped in gtk.

If you really disagree, you can disable this behaviour with SwapOKCancel_Write(false).

[Updated on: Mon, 02 September 2024 00:25]

Report message to a moderator

Previous Topic: Getting the SQL statement without execute it
Next Topic: [SOLVED]sizing problem when adding a Droplist to a Toolbar
Goto Forum:
  


Current Time: Sat Apr 26 02:20:33 CEST 2025

Total time taken to generate the page: 0.00665 seconds