-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to provide TableModelHandler ColumnType for different columns #26
Comments
OK, nevermind. I figured it out by typing in the following: @model_handler.ColumnType = rbcallback(4, [1, 1, 4]) do |_, _, column|
# return value based on column |
Hi Andy! Test page16.c in andlabs/libui is a good reference on how to use the table. Here, they use if statements to set the type of each column. static uiTableValueType modelColumnType(uiTableModelHandler *mh, uiTableModel *m, int column)
{
if (column == 3 || column == 4)
return uiTableValueTypeColor;
if (column == 5)
return uiTableValueTypeImage;
if (column == 7 || column == 8)
return uiTableValueTypeInt;
return uiTableValueTypeString;
} mh.ColumnType = modelColumnType; In Ruby, it would be something like this: model_handler.ColumnType = rbcallback(4, [1, 1, 4]) do | _mh, _m, column|
case column
when 3, 4
3
when 5
1
when 7, 8
2
else
0
end
end All column types can be referenced from here. _UI_ENUM(uiTableValueType) {
uiTableValueTypeString,
uiTableValueTypeImage,
uiTableValueTypeInt,
uiTableValueTypeColor,
}; Currently, there is no way to reference Thank you!
|
I see you have resolved the issue. |
Thanks a lot for the response. I did need to figure out the numbers to return for each column type, so this is very helpful. |
Hi,
I have a new question. I noticed that in your implementation of examples/basic_table.rb you provide a single static value for
model_handler.ColumnType
:examples/basic_table_image.rb also had similar code:
This works well if all columns are the same type, but what if the columns are of different types like one text column and one image column? How do you modify the code to handle the variety of columns? And, do you have a quick link/reference for what each column type value is for all column types?
I'd be very grateful for any help with this.
Andy
The text was updated successfully, but these errors were encountered: