Actions on individual controls in a table cell?

Questions and information about Crank Software's Storyboard Designer

Moderator: jamiev

Actions on individual controls in a table cell?

Postby stubbornthings » Wed Mar 21, 2018 2:30 pm

Is it possible to assign an action to individual controls I have for the rows in my table?

For instance, I want a Lua function to be called when the user touches a Text control in a table row and I want a seperate function to be called when the user presses an image control.

Is this possible? And if not, could you suggest a way I can handle this?

Thanks in advance.
stubbornthings
 
Posts: 15
Joined: Tue Aug 02, 2016 3:25 pm

Re: Actions on individual controls in a table cell?

Postby MikeMarchand » Thu Mar 22, 2018 8:12 am

Hi stubbornthings,

You can add a different Lua callback for each column. There is no direct way of having different callbacks for each row but what you can do is on the Lua side, use mapargs.context_row to get the row number. You can then invoke different Lua functions depending on the row number.

Hopefully this helps.

Cheers,
Mike
MikeMarchand
 
Posts: 30
Joined: Wed Jan 21, 2015 3:33 pm

Re: Actions on individual controls in a table cell?

Postby stubbornthings » Thu Mar 22, 2018 8:26 am

Hi MIke,

Thank you but I'm not sure that answers my question. I'd like to know how to call separate Lua functions for individual controls in a table cell.

I'm not sure I can use columns as each cell must contain the same controls, I think.

Here is a screenshot of my screen. The white bar on the right side contains three controls (Setting Label (text), 1000 (text), and an image). I want to be able to assign separate Lua callbacks for each one of these controls.

Capture.PNG
Capture.PNG (17.61 KiB) Viewed 1839 times
stubbornthings
 
Posts: 15
Joined: Tue Aug 02, 2016 3:25 pm

Re: Actions on individual controls in a table cell?

Postby MikeMarchand » Thu Mar 22, 2018 1:00 pm

Firstly, a table's columns are based off a column template. Creating a different template for each column will allow you to have one column with text and another with images. This will also allow you to place different actions for each column.

I've attached a simple sample project that demonstrates how to call separate Lua functions for each column and how to handle events differently depending which row they are on.
table_example.zip
Example Table Application
(105.44 KiB) Downloaded 59 times


There is a lock icon on the rightmost column, pressing it will toggle the lock state. There is a user icon, pressing it will toggle the selected state, unless it is locked, in this case it will do nothing.
table app.png
table app
table app.png (13.7 KiB) Viewed 1810 times


Take a look at the Properties for the Table itself, you will see a different Table Cell Template is assigned to each column. The Actions are placed on the Cell Templates, allowing different column to invoke different Lua functions.
table_properties.png
table properties
table_properties.png (16.93 KiB) Viewed 1810 times


Hopefully this helps.

Cheers,
Mike
MikeMarchand
 
Posts: 30
Joined: Wed Jan 21, 2015 3:33 pm

Re: Actions on individual controls in a table cell?

Postby stubbornthings » Thu Mar 22, 2018 1:05 pm

Thanks Mike.

I actually figured that out myself this morning but I'm glad you explained it in detail (and with a sample project). This will help.

Cheers!
stubbornthings
 
Posts: 15
Joined: Tue Aug 02, 2016 3:25 pm


Return to Storyboard Designer

Who is online

Users browsing this forum: No registered users and 2 guests