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 » Toolbuttons
Toolbuttons [message #24974] Sat, 06 February 2010 17:58 Go to next message
gedumer is currently offline  gedumer
Messages: 21
Registered: March 2006
Promising Member
There doesn't appear to any documentation on Toolbuttons, so... I have two questions:

1. I need to know how to make a Toolbutton work like a Buttonoption Class with a pushed state and up state.

2. I also need to know how to change a "Tip" on a Toolbutton in that buttons' event code. I set the initial tip when I add the toolbutton, but I want to change it in the event code.
Re: Toolbuttons [message #24987 is a reply to message #24974] Sat, 06 February 2010 22:00 Go to previous messageGo to next message
gedumer is currently offline  gedumer
Messages: 21
Registered: March 2006
Promising Member
gedumer wrote on Sat, 06 February 2010 11:58

There doesn't appear to any documentation on Toolbuttons, so... I have two questions:

1. I need to know how to make a Toolbutton work like a Buttonoption Class with a pushed state and up state.

2. I also need to know how to change a "Tip" on a Toolbutton in that buttons' event code. I set the initial tip when I add the toolbutton, but I want to change it in the event code.


Anyone have any ideas on this?
Re: Toolbuttons [message #24989 is a reply to message #24987] Sat, 06 February 2010 22:42 Go to previous messageGo to next message
alendar is currently offline  alendar
Messages: 47
Registered: January 2010
Location: Idaho, USA
Member
I think the tip is named something different in the object than "tip". You should just be able to set it to a string.

I'm going to have to add a tool bar to my app, so I'll take a look. Isn't there an example anywhere in the examples or bazaar folder?


cd7651feeb698f6ac6cec1f6deda5e5b
Re: Toolbuttons [message #24993 is a reply to message #24989] Sat, 06 February 2010 22:57 Go to previous messageGo to next message
gedumer is currently offline  gedumer
Messages: 21
Registered: March 2006
Promising Member
It's easy to set the Tip when you add the toolbutton (which is not documented AFAIK). The problem is I want to change the text under certain conditions in the event code.
Re: Toolbuttons [message #25003 is a reply to message #24993] Sun, 07 February 2010 04:50 Go to previous messageGo to next message
alendar is currently offline  alendar
Messages: 47
Registered: January 2010
Location: Idaho, USA
Member
Ok, finally got it to work. I'm a bad typist. The main thing is if you use the example in the help file, you won't have an object to reference, or you will, but you'll have to pull it off the vector and I don't know if it is exposed.

I find it easier to create the ToolButton explicitly, set its attributes and add it to the ToolBar, like this:

1) Create the toolbar and button on my class spec:

ToolBar toolbarFrame;
ToolButton repeat;

2) In the callback, configure and add the button:

void toolbarFrameCallback(Bar &bar) {
repeat.WhenAction = THISBACK(RepeatSongs);
repeat.Tip("Boo!");
repeat.Image(MyImages::misc());
bar.AddMenu("Function",
MyImages::misc(),
THISBACK(MenuFn));
bar.Add(repeat);
}

3) Where ever you like, change the tip:

repeat.Tip("Hoo!");

Works fine.

I haven't got the toggle state yet, but I need it for my project.


cd7651feeb698f6ac6cec1f6deda5e5b
Re: Toolbuttons [message #25004 is a reply to message #25003] Sun, 07 February 2010 04:58 Go to previous messageGo to next message
alendar is currently offline  alendar
Messages: 47
Registered: January 2010
Location: Idaho, USA
Member
Well, that was hard - not.

To do a toggle, you just do this in the event handler:

void RepeatSongs() {
repeat.Check(!repeat.IsChecked());
}

It flips it on and off when clicking. Doesn't get much easier than that. EXCEPT -- the ButtonOption has the "=" operator overridden for boolean so you can just:

repeat = !(repeat.IsChecked());

sigh, so much time is wasted without this obfuscation. Evil or Very Mad


cd7651feeb698f6ac6cec1f6deda5e5b
Re: Toolbuttons [message #25018 is a reply to message #25004] Sun, 07 February 2010 16:09 Go to previous messageGo to next message
gedumer is currently offline  gedumer
Messages: 21
Registered: March 2006
Promising Member
Thanks for your help.

[Updated on: Sun, 07 February 2010 16:29]

Report message to a moderator

Re: Toolbuttons [message #25019 is a reply to message #25018] Sun, 07 February 2010 16:27 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
With ToolButton you need to do the state toggling manually, similar to the code above.
Previous Topic: v.1952 errors
Next Topic: TopMost
Goto Forum:
  


Current Time: Fri Mar 29 12:24:57 CET 2024

Total time taken to generate the page: 0.01518 seconds