Skip navigation.
Home
The QNX Community Portal

View topic - Dynamic callbacks for label

Dynamic callbacks for label

Discussions, suggestions, requests about this website.

Dynamic callbacks for label

Postby pradeep » Tue Apr 03, 2012 10:03 am

Hi,


I have created a GUI screen consisting of buttons(48) ,labels(48) and one slider(1). My problem is that i have only one slider but i need to update 48 labels,which label to be updated is defined by the button pressed and once the label is selected then the slider updation values must be displayed in that label. Please suggest me how to achieve this.
pradeep
Active Member
 
Posts: 20
Joined: Tue Aug 09, 2011 7:17 am

Re: Dynamic callbacks for label

Postby maschoen » Tue Apr 03, 2012 5:55 pm

I'm going to assume that by "button pressed" you either mean the last button pressed, or you are using "radio" buttons, where only one stays pressed, and pops out when another is pressed.

There are a number of ways to do this, but I think some are better than others.

You could have 48 button callbacks, each one setting a variable indicating the button was pressed.
When the slider is moved, it could use this variable as an index into a table with the label widget pointers.
I would call this the hard way.

The buttons could all call one callback. In that callback you search a table of button widget pointers to find which one was pressed, and store the index. The index could also reference a table of label widgets that the slider would use.
This is ok, but needs a table search each time a button is pressed.

The following would be my choice, as there is very low overhead, although searching a 48 item table whenever a human action occurs is not many cycles.
The buttons could all call one callback. In that callback you read the widget's user-data. You've previously stored something in the user-data which you retrieve and store in a global variable. This could either be an index as in the above example, or the label widget pointer itself.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Re: Dynamic callbacks for label

Postby pradeep » Wed Apr 04, 2012 5:33 am

Thanks for the quick reply

I have tried same thing with slight modification

What i have done is that I have obtained the button index with Ptgetresource and then using this index value i have updated global array and used the index value in the switch statement in the slider callback to update the label text instead of going to the label callback.

Suggest if any mistake exist.

The process worked fine except one problem.

I have named the textbox as AO while realizing for the first time and then while updating text for the text box from the slider callback the value is being backside of AOi.e., AO is visible and also value that i am changing through slider is being updated.

Suggest solution for this problem.
pradeep
Active Member
 
Posts: 20
Joined: Tue Aug 09, 2011 7:17 am


Return to OpenQNX Site

Who is online

Users browsing this forum: No registered users and 1 guest