09-18-2014 05:30 AM
Hey everyone,
I made a matrix table of buttons (please open my attached picture to understand what I meant).
I would like to do two things:
1. Make the buttons clickable, and to make an event each time one of them was clicked by the user.
2. To control the color of each button sepertly in the table.
I use CVI 2013 with academic lessons.
Are that possible? and which are the commands I can use for these tasks?
Best,
Tom
Solved! Go to Solution.
09-19-2014 02:10 AM
Button cells are already active provided the table is in hot or normal mode.
If in hot mode, you receive an EVENT_COMMIT in the table callback: you can then detect the button pressed calling GetTactiveTableCell and processing cell coordinates.
Individual cells can be painted in color provided the panel the control is on is not set to follow Windows theme: edit panel attributes, select Other attributes... and uncheck Use Windows Visuali Styles for Controls checkbox.
Alternatively, the table alone can be set this way leaving the panel and other controls to adhere to the theme: you can obtain this by calling:
SetCtrlAttribute (panelHandle, PANEL_TABLE, ATTR_DISABLE_PANEL_THEME, 1);
In this case, individual cells need to be painted programmatically by calling:
SetTableCellAttribute (panelHandle, PANEL_TABLE, MakePoint (col, row), ATTR_CMD_BUTTON_COLOR, VAL_CYAN);
where col, row are 1-based column and row indexes of the cell to operate on. The function will fail if the cell is not a button.
09-19-2014 07:08 AM
Thanks a lot!! It worked!
May I ask another question about tables?
When the user choose a cell from the table, I could get the cell's coordinates into the point structure Cell from this series of commands:
case EVENT_LEFT_CLICK:
Point Mouse_Coords, Cell;
Mouse_Coords.x = eventData2;
Mouse_Coords.y = eventData1;
GetTableCellFromPoint (panelHandle_3, ilfmaker_ilftable, Mouse_Coords, &Cell);
But when the user mark the entire column or the entire row by pressing the first column from above or row to the left, I want that the event would go over the entire row/column, instead nothing is happened.
Moreover, I am unable to get the column/row coordinates in this case only Cell.x and Cell.y 0,0.
Thank you,
Tom
09-19-2014 07:21 AM
When the user clicks on a row or column header it selects the entrire row/column: in this case an EVENT_SELECTION_CHANGE is sent to the table callback: in this case you can trap that event and use GetTableSelection to obtain the selected area in a Rect structure.
Be careful in doing so: if the user manually selects a set of cells with mouse or keyboard you will receive a series of EVENT_SELECTION_CHANGE events that you must properly handle.
09-19-2014 02:33 PM
If it turns out that EVENT_SELECTION_CHANGE is unreliable for this purpose, you can look for EVENT_TABLE_ROW_COL_LABEL_CLICK instead.
09-21-2014 02:28 AM
Wow guys!!! thank you so much!!! this event was exactly what I needed! 🙂