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 » U++ Library support » Menus&Toolbars » ToolBar enabling and disabling question
ToolBar enabling and disabling question [message #21451] Thu, 21 May 2009 12:12 Go to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello all

Just a simple question.

I want to enable or disable an option in a ToolBar depending in this case if a text has been changed or not.

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

For a MenuBar it is easy to do it, but for a ToolBar I do not know the way.

I have tried to do it by a Timer function that calls every 3 seconds to UpdateLayout() and other functions, bot no success.

How can I force a ToolBar to update its layout?.

Best regards
Koldo
  • Attachment: ToolBar.JPG
    (Size: 1.29KB, Downloaded 956 times)


Best regards
Iñaki
Re: ToolBar enabling and disabling question [message #21454 is a reply to message #21451] Thu, 21 May 2009 15:47 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

koldo wrote on Thu, 21 May 2009 13:12

Hello all

Just a simple question.

I want to enable or disable an option in a ToolBar depending in this case if a text has been changed or not.

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

For a MenuBar it is easy to do it, but for a ToolBar I do not know the way.

I have tried to do it by a Timer function that calls every 3 seconds to UpdateLayout() and other functions, bot no success.

How can I force a ToolBar to update its layout?.

Best regards
Koldo


It is same as MenuBar

Locking to uppsrc is two method:
1. if you set a control, set enable or disable this control
2. if is calback with text or/and image

you need use this method
Bar::Item&  Bar::Add(bool enable, const UPP::Image& image, Callback cb)


and example you can find in uppsrc/ide/idebar.cpp at line 379 like this:
void Ide::BuildMenu(Bar& menu) {
..........
	b = b && idestate == EDITING; // set enable or disable
=>HERE	menu.Add(b, AK_CLEAN, THISBACK(Clean))
		.Help("Remove all intermediate files");
.............
}

and every time when you want to refresh bar you need call like this:
YOUR_TOOLBAR_CTRL_OBJECT.Set(THISBACK(YOR_CONSTRUCTOR_BAR_FUNCTION));
Re: ToolBar enabling and disabling question [message #21455 is a reply to message #21454] Thu, 21 May 2009 16:18 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Other method, maybe what you need... you need to save your references of item Bar::Item& when you add items, when you want to enable or disable you need to call method Enable(IS_NEABLE)
Re: ToolBar enabling and disabling question [message #21456 is a reply to message #21451] Thu, 21 May 2009 16:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Thu, 21 May 2009 06:12

Hello all

Just a simple question.

I want to enable or disable an option in a ToolBar depending in this case if a text has been changed or not.

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

For a MenuBar it is easy to do it, but for a ToolBar I do not know the way.

I have tried to do it by a Timer function that calls every 3 seconds to UpdateLayout() and other functions, bot no success.

How can I force a ToolBar to update its layout?.

Best regards
Koldo


You need to set it again.

See examples/UWord, UWord::SetBar and calls to it.

This perhaps might be automated, which was sort of idea at some time in the past, but in the end I have found that calling 'SetBar' after each change is quite trivial...

Mirek
Re: ToolBar enabling and disabling question [message #21462 is a reply to message #21451] Thu, 21 May 2009 17:11 Go to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Thank you tojocky and luzr Smile

I tried all but simply doing:

YOUR_TOOLBAR_CTRL_OBJECT.Set(THISBACK(YOR_CONSTRUCTOR_BAR_FU NCTION));

Best regards
Koldo


Best regards
Iñaki
Previous Topic: Only one additional argument for Bar callback?
Next Topic: Disable/Enable Menu item during runtime
Goto Forum:
  


Current Time: Fri Apr 19 03:57:57 CEST 2024

Total time taken to generate the page: 0.02609 seconds