![]() |
|
#1
|
|||
|
|||
Button press needs recognitionGreetings! This is my first post to this fine forum which I've found quite valuable. Thanks Mark for the reply to my private email.
My problem here is getting a button to be recognized when a routine is running. I've tried to simplify what I am seeking by writing a small demo of two buttons and a progress bar. One button (Start) callback starts a loop counting seconds and displaying the progress on the bar. (I finally stumbled on "flush" to update the window display during the loop iterations!). The 2nd button (Stop) should cause the cessation of the loop -- but currently will not be recognized until the loop in the start callback returns. Is there a way around this? Pointers to previous forum threads, examples, etc would be welcome. I'm quite rusty on C/C++ but can usually figure things out. Thanks, Don CPP / C++ / C Code:
|
|||
|
#2
|
||||
|
||||
Re: Button press needs recognitionHello and Welcome to GIDForums™ azark. Code tags on the first post, have a cigar.
Enough of that rot... While I haven't yet run throught your example I'll give you something that might lead you in the right direction. CPP / C++ / C Code:
Perhaps using a timeout to "hijack" the event loop would work for you? 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 Last edited by LuciWiz : 09-Sep-2006 at 05:43.
Reason: Edited at member's request
|
|
#3
|
||||
|
||||
Re: Button press needs recognitionOK azark, here is a stripped down example of your code to show what I am talking about. Instead of just adding a constant value you could check what you are tracking for progress and set your value accordingly.
This will run until either the max value is reached or the stop button is pressed. It will remove the timeout and set the value of the progress bar back to zero if running. If the stop button is pressed the timeout is removed but the value is left untouched. Now add the logic to track the progress of whatever you're tracking and you are on your way. HTH, Mark CPP / C++ / C Code:
__________________
"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 |
|
#4
|
|||
|
|||
Re: Button press needs recognitionHi Mark,
Thank you for both of your examples and replies. The 2nd was most helpful and works just like I was expecting. I spent a lot of time last night fooling around with the add_timeout and repeat_timeout but still could not understand their operation too well. Documentation seems a little sparse. Your latest code certainly illustrates their operation much better. As a side note: I even tried the example in the programming manual under "add_timeout" that is supposed to output "TICK" but got no output results. In my application of FLTK, I'm adapting a command-line interface program which does some unusual output on a serial port to an external device, in the process doing programming of flash and eeprom memory of a microcontroller chip. The timer and progress bar represented (for simplicity) a whole lot of C code that I now need to fashion into the scheme of things. This is being done under Linux (Debian) and a version will be made for MS Windows use too -- hence the attractiveness of FLTK. Have a good day and thanks for the pointers. Don in the North Arkansas Ozarks |
|
#5
|
||||
|
||||
Re: Button press needs recognitionGlad to help. I tried to use your code in the second example as much as I could. Once I gave it a good read I thought that was what you were after.
It sounds like you may have more questions in the future. Good luck with your project and we'll see you at the next bottleneck. 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 |
|
#6
|
||||
|
||||
Re: Button press needs recognitionQuote:
Here is an updated example that will stay alive and wait for the "TICKs". CPP / C++ / C Code:
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 |
Recent GIDBlog
Problems with the Navy (Enlisted) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Change the caption on button when clicked | drewdaman | MS Visual C++ / MFC Forum | 5 | 31-May-2009 20:56 |
| Button class | Spidy08 | FLTK Forum | 8 | 25-Aug-2006 01:52 |
| Server Button Control execute twice | bluebeta | .NET Forum | 2 | 12-Jun-2006 09:25 |
| Group Round buttons (radio buttons) | toaster | FLTK Forum | 1 | 03-Jan-2006 06:57 |
| 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