In Example 9, if you execute
grid.setSelectedRows([0, 1]);
the first two rows are effectively selected. But said selection disappears when clicking a row or traversing them with the arrow keys.
Note that active (related to the clicks/keydowns) and selected (related to the selection model) are two different CSS classes.
How to prevent the mouse and keyboard actions from interacting with the selection model?
If you don't want the active cell tracking affecting the selection, you can set the "selectActiveRow" option in the RowSelectionModel to false.
Related
I have a window which shows a table on the left half. On the right half I display properties of the item which is selected in the table. The user can now change these properties.
The properties are represented by different kinds of controls: textFields, sliders, numberSteppers and popUpButtons.
The user can - besides using the mouse - use the tab key to navigate through the UI Elements. When the table has the focus tab will select the first editable item on the right side, then tab walks through the items and after the last item will go to the table again.
When the table has focus and I change the value of a popUpButton or move a sliderthe default behaviour of the API (Apple's Cocoa) is to change the value but keep the focus on the table.
My intuition would tell me that after changing a control element it should have the focus (i.e. become firstResponder). But I checked some of macOS' preference panes and they behave similarly.
In Apple's Human Interface Guidelines I do not find mention of that specific topic.
So my question is:
Is there a guideline or at least best practice an app should follow regarding if a control element like a popUpButton or slidershould get the focus when clicked or edited?
I'm building a tree store with GTK3 in C in which there are primary rows that are always displayed, and by clicking on the little triangle icon to the left of a primary row, additional secondary (child) rows expand below the primary. As an example, consider that the primary rows could be directories, and when they're expanded, rows below that show the files in those directories. I'm doing this to allow a user to select primary items to be deleted, while the secondary rows are just informational, telling, for example, what files are in the directory, so they'll know if they really want to delete the whole thing.
To enable selection for deletion, the first column contains a GTK_CELL_RENDERER_TOGGLE, and I have a callback associated with the checkbox toggle. Everything works nicely except for one thing. When the user clicks the little triangle item to expand a row, most of the content of the primary row does not appear in the secondary rows (this is expected and desired), but... the checkbox toggle does appear in the first column. Although in a directories/files example that might be meaningful, in my case it makes no sense to think of deleting the content of the secondary rows.
When building the secondary rows, I've tried things like just:
gtk_tree_store_set(TS,&J,2,"filename",-1);
or
gtk_tree_store_set(TS,&J,0,NULL,2,"filename",-1);
hoping that NULL would cause the toggle to be suppressed, but to no avail. GTK still displays a checkbox, probably just interpreting the NULL as a zero.
Is there a way to control (and in my case, suppress) display of the toggle? Or more generally, is there a clean way to control which columns are displayed in child rows? It seems to work with TEXT, but just not with TOGGLE.
A little later: There is a potentially useful function called gtk_cell_renderer_set_visible(), but it requires a reference to the cell renderer. How to acquire that on a per-row or per-cell basis when all I have during construction is the GtkTreeStore and a GtkTreeIter?
There are (at least) 2 solutions:
Base class GtkCellRenderer has visible property. You can add extra field to your model which indicates, whether Toggle should be visible for this row.
If there are other fields in you model which indicate whether it's a primary or secondary row but not directly you can use gtk_tree_view_column_set_cell_data_func to set a function to be called before rendering. There you can call gtk_cell_renderer_set_visible or any other function to set renderer's properties manually.
I have a list view that draws an additional black line when items in the list are modified and there are selected items in the list.
The code iterates over the list and updates the cells using the line of code below:
ListView_SetItem(m_hListCtrl, &lvItem);
Additional rows are added using the ListView_InsertItem macro.
If a row is added and there are other rows selected, the following happens:
The line disappears if the user selects a different row. How can this black line be prevented/removed?
The LVS_EX_GRIDLINES style has a number of bugs associated with it that Microsoft have never bothered to fix, and this is one of them. The workaround is to forcibly redraw the list items when you make the particular changes that trigger the problem. You can redraw a range of list items using the LVM_REDRAWITEMS message, or even simpler just repaint the whole control with InvalidateRect().
I have implemented a slickgrid and activated keyboard navigation.
When the users is scrolling down using the down-arrow key and reaches the last of the currently visible rows, the grid loads a whole new section of rows and places the selection at the top.
My user tests have all included a complaint about this behaviour as they all find the jump jarring.
I would like to implement behaviour, so the grid scrolls just one line at a time, when I press the down arrow while the last visible row is selected.
I was wondering if there might be some setting, I have overlooked, or if anyone has some suggestions for how to approach the task of adding this behaviour.
(the "problem" is the same, when you scroll upwards - only reversed of course)
This is controlled by the doPaging argument in scrollRowIntoView(row, doPaging) (https://github.com/mleibman/SlickGrid/blob/master/slick.grid.js#L2662). There's no setting to control that behavior, but you could easily add one.
It was initially written this way to make keyboard navigation faster since continuously navigating down doesn't have to do as much work as it would have if we were updating the grid on every 'row down'.
I have a datagrid with many columns. This makes it pretty wide. Now we want to add more information to the table. Aside from removing or shortening existing columns what are some ways we might be able to add additional information without adding new columnes.
The data we want to add would be one of several values. For example:
Projected
Actual
Other
For other cases when the value was an off/on or true/false we would change the color of the row. In this case that doesn't seem to be a good option.
Another thing we considered is using an icon to indicate the information.
Any other ways this could be done?
A solution i've seen implemented with grid components is to have a column chooser - some sort of popup dialog that lists the columns and you can select which ones you would like to see in the grid. You should be able to invoke this popup by triggering it from the grid, e.g. it might appear as an option when the user right clicks and causes the context menu to appear.
Can you group related information into tabs?
an overflow area? ie a number of fields underneath the table that populate based on the selected row.
or just only show the minimum needed info and the have full details in a popup when doble clicked or something..
1) Popup on row hover
2) Drop open inline in the grid with extra info on row click
One technique I've used in the past was to create a "container" type of class that has its own labels and textboxes, and you can arrange them however you want, then insert this class into a single grid column. You still have to do some tricks on binding multiple controls that are not native "grid column" controls, but should help you along. Then, you can actually have each row a single container control in a single grid column...
You can't add completely new data to a grid without reserving a column to display it. The best solution I've seen is to provide only the essential information in the grid displaying all records, and then create a drilldown view that shows all of the data for one row. The drilldown can either be a new view in the same form, a popup for an additional window, or perhaps a mouseover popup.
I've worked on systems that use all sorts of shortcuts to display every last bit of information on a single page, and I found that it just made everything more confusing and harder to use. "Oh, that little icon there means that <insert something totally unrelated to the icon picture>."