I'm trying to programmatically set a dgrid row as active, not just selected. I have a dojo dgrid OnDemandList which is using the Selection and Keyboard Mixins.
Using the select(row) method I can programmatically select a given row, but that row is not active. When a row is active, I can use the Up and Down arrow keys to navigate to the rows above and below it. When a row is just selected, the row is highlighted but the arrows keys do not work.
Clicking the row with the mouse will make it active and selected, but I'm trying to build my interface to be 100% usable with just the keyboard.
Ok, took me awhile but got it figured out. What I was really trying to do was add focus to a row. The code for doing that was in dgrid/Keyboard.js under the _focusOnNode method.
The actual code to change focus from row currentFocusedNode to row focusedNode is:
if(currentFocusedNode){
// Clean up previously-focused element
// Remove the class name and the tabIndex attribute
put(currentFocusedNode, "!dgrid-focus[!tabIndex]");
if(has("ie") < 8){
// Clean up after workaround below (for non-input cases)
currentFocusedNode.style.position = "";
}
}
if(has("ie") < 8){
// setting the position to relative magically makes the outline
// work properly for focusing later on with old IE.
// (can't be done a priori with CSS or screws up the entire table)
focusedNode.style.position = "relative";
}
focusedNode.tabIndex = grid.tabIndex;
focusedNode.focus();
put(focusedNode, ".dgrid-focus");
The code above is really just a code fragment, for it to work you will have to declare "dojo/has" and "put-selector/put" first as well as define the currentFocusedNode and focusedNode. But I'm leaving that as an exercise for the reader ;-)
Also note that this only changes the "focus", it will not select the focusedNode but that can easily be done using grid.select(focusedNode);
Related
I have a Dialog and there is a Table (Tableviewer) inside it.
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI);
Certain columns of my table are editable. I click on the cell, I edit the value, I leave the cell and the edited value immediately reverts back to the old one.
What should I configure/set in table/tablehelper to make the edited values last longer than the time I spend in the cell?
EDIT!-----------------------------
We have a Helper class that is responsible for creating CellEditingSupport like this:
`
if ("w".equalsIgnoreCase(hd_bean_mode)) {
CellEditingSupport editingSupport = new CellEditingSupport(viewer,pds[i]);
col.setEditingSupport(editingSupport);
}`
This class itself is quite complex and does a lot of magic through reflexion, etc... The funny thing however is that other tables use this very same Helper class, seemingly with the same configuration and they work!
One more thing: I am conviced that the columns in my table get the Editingsupport. I know it because of the debugger and because the cells are editable. The only problem is that those edits do not last long.
A user is editing a value in a property grid, then he clicks a button outside the property grid which executes code to read the property values. Sometimes the OLD value of the property is read, rather than the new value which was being edited. I have to tell the users that they must complete the editing, by hitting return or clicking on another property before clicking any buttons outside the grid. They forget, and report a bug.
I would like to make this foolproof. Perhaps by forcing the current edit to complete when the mouse leaves the property grid.
I know how to handle the mouse leaving event. I do not know how to force the property grid to accept any partial edits.
I have tried, as a hint to the user,
pg = new wxPropertyGrid( ...
....
if( ! pg->EditorValidate() )
{
SetStatusText("Please complete editing");
return;
}
but EditorValidate() always returns true
Found it!
wxPropertyGrid::CommitChangesFromEditor()
http://docs.wxwidgets.org/trunk/classwx_property_grid.html#a6e06d92a622237457fea00372df1eaae
I've encountered this in a couple spots in my app:
Let's assume I have 3 items in a carousel. I'm viewing item #2. I need to reload that carousel, so I do the following operations:
Ext.getCmp('carousel_name').removeAll();
var new_objects = (bunch of code that recreates the carousel's objects again, with the same IDs; this is the same code that was used to create the objects the first time, so it is likely not the issue)
Ext.getCmp('carousel_name').add(new_objects);
In the carousel object items list (Ext.getCmp('carousel_name').getItems()), all three items exist. However, only #1 and #3 (the ones which weren't the active item prior to the carousel reload) actually appear. #2 presents a blank white screen, and in the HTML nothing exists except for the item shell markup (no code that I've written shows up). If I do Ext.getCmp('carousel_item_2').show();, the item does appear, but is full-screen, and I get the error:
[DEPRECATE][Ext.Panel#show] Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component);
When I try to manually add that item to either the Viewport or the carousel, nothing is fixed.
I've tried inserting a dummy item in-between removal and reinsertion of new items, that doesn't work. Nor does hiding the entire Viewport before doing any of this and showing it afterwards. Nor does using setItems() rather than add(). Nor does doing Ext.getCmp('exercises_carousel').each(function(item){ item.destroy(); }) rather than removeAll(true)
I don't believe the issue is the code snippet that re-creates the new items, since it's the same code that's used to create the items the first time, and there are no issues on the first creation.
Pretty stumped here.
EDIT: I've found that if, when I get to the end of the carousel, if I add a empty item after the last item in the carousel, I don't get the blank item at N-2. No clue why this is the case. Still not a real solution, it's a hack.
Assuming there are no problems in your code snippet to re-populate new items in your carousel, then the only problem is because of this issue (I'm not sure whether it's a bug in Sencha Touch 2.1 or not but it does exist): when you call yourCarousel.removeAll() and add some new items again, your carousel will NOT set proper active item.
I've seen a similar problem and I added this after adding new items, which works:
carousel.setActiveItem(0);
Alright, this is a hack, so if anyone has a legitimate solution, that would be awesome. But the hack does work, so here it is:
Add an empty item in the carousel
Set active item to the new empty carousel item
Destroy all carousel items
Recreate (and re-add) all of the items
In code:
Ext.getCmp('carousel_name').add({});
Ext.getCmp('carousel_name').setActiveItem(Ext.getCmp('carousel_name').getMaxItemIndex());
Ext.getCmp('carousel_name').removeAll(true);
var new_objects = (bunch of code that recreates the carousel's objects again, with the same IDs)
Ext.getCmp('carousel_name').add(new_objects);
EDIT: As it turns out, this for some reason works 90% of the time; for some unknown reason 10% of the time it still doesn't get inserted. The only way to guarantee that all items get inserted correctly is to clear the entire viewport (Ext.Viewport.removeAll(true)), recreate all of the original items in the viewport, and reinsert them. I'd rather not have to do this every time an item doesn't get inserted.
I just noticed a problem when my user-interface is in a certain state. I have a table view with two columns both of which the user can enter data that is to be used later. There's also a button which acts upon the contents of the table view.
The problem is if the user has entered new data in the column but has not yet exited the field by using the tab key or return key (i.e. the cursor is still in the field and in editing mode) and the button is pressed the old value is used not the current value sitting in the field.
What is the best way to handle this this? I want to use whatever the user has entered thus far.
Basically, The button code needs to tell the text field to finish completion or exit the editing mode. But I can't seem to find a method that will do that.
Use bindings. In Interface Builder, select the table column and in the Inspector go to Table Column Bindings and set the Value content binding appropriately and ensure the "Continuously Updates Values" option is checked. Then changes to the table cell content will propagate immediately.
Found the answer, At least for me.
Find out if a row is selected and if so deselect it. This causes the current entry to be completed.
- (void) completeTableEntry
{
// If a column is selected ensure it is completed
NSInteger sr = [keyValueTable selectedRow];
if (sr != -1) {
[keyValueTable deselectRow:sr];
}
}
How about:
[theTargetWindowWhateverThatIs endEditingFor:nil];
theTargetWindowWhateverThatIs may be, for example, self.window if you are inside a NSWindowController.
I want to programmatically set the focus to the last row (bottommost, its only one column wide) in the DataGridView control for Visual Basic. How can I do so?
So far, I have tried
DGV.Rows.GetLastRow(DataGridViewElementStates.Selected)
without success, though I did not expect that to work.
It absolutely must select that last cell. Otherwise, the application is nearly impossible to use!
Here is a screenshot of what I am making with this: http://www.mediafire.com/?mmyogzytgzt
The "Paste Clipboard Contents" button only pastes into the selected cell, though I guess I could find a workaround.
I solved it. I used a workaround to add the text in directly. I don't need this anymore!
To select the last column, last row in c# (sorry I don't have a vb project I'm working right now:
this._dg.ClearSelection(); // eliminates what they already have selected if you need
this._dg[this._dg.ColumnCount-1, this._dg.RowCount-1].Selected = true;
In VB.net replace 'this' with 'me', and [] with ().
This is also useful:
this._dg.Focus();
this._dg.CurrentCell = this._dg[this._dg.ColumnCount - 1, this._dg.RowCount - 1];
this._dg.BeginEdit(false); // true if you want all text highlighted
// for deletion or replacement