|
|
On 10/16/20 5:48 PM Dave Branson wrote:
I am new to the use of FLTK, and am having a problem with my initial
test use of the Value Slider widget. I am attempting to use this slider
to extract values for a controls project, but cannot seem to grab the
current value as the slider is exercised. A sample of my test code is
below. Any advise would be welcomed.
Hi Dave,
it's great that you posted your code, but an image is not very helpful.
You can attach your source file (.cxx, .cpp, whatever) here w/o issues.
If we had the source code we could easily (test and) modify it to show
you how to proceed.
Another important info would be the OS and compiler/toolchain you're
using. If it's Windows (maybe VS ?), then printf doesn't work as you may
assume.
That said, your code does only print the value right at the beginning of
the program (what does it print, BTW?) but not during runtime when the
slider is moved.
(See also Ian's post which I saw while writing this.)
I understand that the latter is what you want. If you want to access the
value during runtime you need either a callback or another means like a
button or timer to access the value whenever you need. The most direct
way would likely be a callback with an appropriate when() condition that
gets triggered when the slider is moved, something like (untested!):
void slider_cb(Fl_Widget *w, void *v) {
Fl_Value_Slider *sl = (Fl_Value_Slider *)w;
printf("Slider value = %d\n", sl->value());
}
But note, this is not going to output anything if you're using Windows.
Please ask again if you need further advice.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/788021be-a1f2-7029-fcb9-c27839979e9d%40online.de.
[ Direct Link to Message ] | |
|
| |