xforms-development
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XForms] Looking for simple example


From: Jens Thoms Toerring
Subject: Re: [XForms] Looking for simple example
Date: Sat, 8 Nov 2014 01:00:52 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Jon,

On Fri, Nov 07, 2014 at 02:43:24PM +0000, jon wrote:
> I have never used xforms before and am looking for a simple example.
> 
> I need to write a front end for a mixer, what I need is a moderately
> large number of slider controls.
> 
> In an ideal world I would like an array of slider controls, with only
> one handler. Is this possible, if so can anyone point me at an example
> structured like this.

This sgouldn't pose a problem. Any number of objects can be
set up to invoke the same callback ("handler") function. As
you may have already noticed, setting a callback function
for an object with fl_set_object_callback() takes three
arguments: first the pointer to the object, then the func-
tion pointer and, finally, a long integer number. Both the
(pointer to the) object and the number from the tird argu-
ment are going to be passed to the callback function.

If you use a different number for each of your sliders when
setting its callback function you should easily be able to
distinguish within the callback function for which one of
them it was invoked. So the same calback function, when
written appropriately, should be able to deal with being
called for lots of different objects!

If you have an array of sliders then one way to deal with
it might be to call fl_set_object_callback() on each of
them with, for example, the index into the array of sliders
as the third argument (assuming that that array pf sliders
is a global variable). When the callback function is called
then its first argument is the (pointer to the) slider object
itself and the second one is that index.

There's also another way to skin the cat if that won't do:
the callback function receives, as its first argument, the
address of the object it was invoked for. And each object
structure has three user-definable fields (copied directly
from "forms.h":

    void   * u_vdata;        /* anything the user likes */
    char   * u_cdata;        /* anything the user likes */
    long     u_ldata;        /* anything the user likes */

So, if the mechanism of setting a (long int) number when
setting the callback function doesn't suit your needs, using
one of those members of the FL_OBJECT structure should allow
you to distinguish which objects the handler (callback func-
tion) was invoked for and what to do.

I don't know if this helps you (it's not an example, but I
don't have one at the moment). If not, please don't hesitate
to ask for more infornations/examples.

                       Best regards, Jens
-- 
  \   Jens Thoms Toerring  ________      address@hidden
   \_______________________________      http://toerring.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]