![]() |
|
#1
|
|||
|
|||
Button classHi-
What im looking for: I have two button, I want a button to be highlighted (change color) when clicked on, and when the second button is clicked on, it get highlighted and the first one go back to normal. What I got: I've created a button class, got my own draw and handle function, I got it to change color when click on, but I don't know how to tell which button got click on so that I can change the other button back to the original color. any idea? Thanks. |
|
#2
|
||||
|
||||
Re: Button classHello and Welcome to GIDForums™ Spidy08. Your first two posts here sound like interesting things to play with. In order for anyone to offer you helpful information though, you will have to do a few things.
First, read the Guidelines Thread for some good information that will go a long way toward getting help that is actually helpful. It outlines some special syntax highlighters we have for your use here as well as general information on describing your problem. As I request to anyone new here, please let us know what version of FLTK you are using. Some people use the latest subversion repo stuff, others the packaged snapshots. Include your code in your post. This is the most important. You will find that the replies you get will be more in line with your coding that way. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#3
|
|||
|
|||
Re: Button classQuote:
Since you are deriving a new class anyways, you can add a member that keeps a pointer to the other partner button and use that to find out which button to change. Or you just use two different callbacks to toggle button colors around. |
|
#4
|
|||
|
|||
Re: Button classHi -
Sorry... here is more information. FLTK version 1.1.7 What I got here is a black rectangle on top of a purple rectangle, and when the black one is clicked on, the one in the back change its color to yellow. I want two obj of this class and want only one of them to be selected at one time, so if obj 1 is selected, I only want that border color to change, then when the second one is selected, the first one should change back to purple. Pretty much like a on/off button... I just need a way to detect which one is selected, and since their both using the same class, I don't know how to do it. Unless there is another way to highlight border... this is easier in vb. CPP / C++ / C Code:
CPP / C++ / C Code:
Last edited by cable_guy_67 : 24-Aug-2006 at 08:22.
Reason: Please surround your FLTK code with [cpp] YOUR CODE HERE [/cpp]
|
|
#5
|
|||
|
|||
Re: Button classYou can use a Fl_Toggle_button instead and read Fl_Toggle_button::value(). If you get 1, it's on. If you get 0, it's off. You can then also read or set the other buttons in your interface with value() and value(int);
|
|
#6
|
|||
|
|||
Re: Button classSorry im kinda slow here.... so bare with me.
Fl_Toggle_Button will only toggle the value of that button right? I don't want the value to toggle until the second button is push. Not sure how to use the callback routine. CPP / C++ / C Code:
Last edited by LuciWiz : 24-Aug-2006 at 15:21.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#7
|
|||
|
|||
Re: Button classQuote:
I'll keep my clothes on if you don't mind ;-) Anyway, how about this: CPP / C++ / C Code:
|
|
#8
|
|||
|
|||
Re: Button classOk.. tried your way... didnt work... so i use some of ur code with mine... and it work perfectly. But it seem like a lot of codes just to do a little thing.
Thanks a lot for ur help. CPP / C++ / C Code:
Last edited by cable_guy_67 : 24-Aug-2006 at 10:46.
Reason: Changed CODE tags to CPP tags for syntax highlighting
|
|
#9
|
|||
|
|||
Re: Button classoverloading is more powerful, but if you just want a simple example:
CPP / C++ / C Code:
|
Recent GIDBlog
Developing GUIs with wxPython (Part 2) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C++ class -- Please help | vnca_1 | C++ Forum | 3 | 14-Jun-2006 12:31 |
| a tester class and then some. | postage | Java Forum | 1 | 06-May-2006 15:48 |
| Group Round buttons (radio buttons) | toaster | FLTK Forum | 1 | 03-Jan-2006 06:57 |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | C++ Forum | 2 | 19-Dec-2004 06:06 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 03:38 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The