What event to call when ListView selected item changed? - delphi

I'd like to run a procedure--once--whenever the selected item in a ListView changes. The obvious choice would be OnSelectItem, but it's called twice when the user moves from one selected item to another (using mouse or arrow keys). Similarly, OnChange is called three times when moving between items.
Is there an event generated only once under these conditions? OnClick is generated once, but doesn't cover moving between items using arrow keys, etc.

You can do it like this using OnSelectItem.
Remember the last selected item.
When the OnSelectItem fires, check if the current selected item differs from the one you remembered.
If so, perform your task, and make a note of the new selected item.

Related

How to remove a selected item on KeyDown event in PaperJS

First steps with PaperJS. I realized this sketch and this video to describe the issue. As you can see in the video, drawing, for example, three items, and moving over them to select one and pressing the "d" key on keybord, it is possible to remove just the last added and selected item, but not the previous ones. If you start from the first or second item of the three added, the alert is not even triggered.
The wanted beaviour would be instead to select the event.item.selected (moving on it with the mouse) and remove just the selected one by clicking the "d" key on keyboard.
Thank you for your help
Your issue is that after removing the first path, your path variable no longer points to nothing.
So the next time you hit the delete key, you no longer know the selected path.
What you should do instead is storing the currently selected path into another variable and use it instead.
Here's a corrected sketch based on your code, demonstrating this.

How to select just one row, prevent to unselect item in singleselect mode

My question is very simple but I really didn't find any solution here.
I have a Table setSelectable(true), setMultiselect(false), setImmediate(true).
It works fine by first click and moving through the table using arrows.
But if I click again to the row already having been selected,
then it becomes unselected. How to prevent it?
I'd like to have kept just one row always selected.
As from the Vaadin Book here:
If the user clicks on an already selected item, the selection will deselected and the table property will have null value. You can disable this behaviour by setting setNullSelectionAllowed(false) for the table.
So:
table.setNullSelectionAllowed(false);

I need a DBGrid OnAfterCellClick

I have three DBGrids and three Tables, and two of them are linked with Master Fields and work as expected. When the user clicks on grid-1, it shows three items in grid-2.
When the user clicks on grid-2, I want to use Locate to select the Row in grid-3
Problem is that the grid-2 OnCellClick event is fired before the data has changed to the appropriate Row. e.g.
Grid-2
Flowers <-- this has focus and Dirt has focus in grid-3
Weeds
Trees <-- then I click here
Grid-3
Dirt
Water
Gum <-- and using Locate in the grid-2 OnCellClick I
want it to show Gum but grid two is still
internally on Flowers and stays on Dirt
It seems that the grid does not change to the Row until after the OnCellClick event.
I need an AfterCellClick event.
Can someone please shed some light on how to go about that?
Thanks
You shouldn't be using OnCellClick. Use the TDataSet.OnAfterScroll instead. It's called automatically when the record (row) pointer is moved, after the movement is done. This means that when the grid attached to the second table is clicked and the record pointer is moved from Flowers to Trees, the second table's OnAfterScroll event will be fired after the row changes, and in that event handler you can do the appropriate Locate in the third table.

sortable list trigger is a specific object

So I have a normal jQueryUI Sortable List IE: http://jqueryui.com/sortable/#default
However I would like the drag(or sort) event only to be triggered when the user clicks on a specific object inside my list item. For the sake of the example lets say the arrows in the link I provide would trigger the drag event but clicking on the text wouldn't.
Suggestions?
You can use the handle option
http://api.jqueryui.com/sortable/#option-handle

How do I move multiple nodes at once in a TJvTreeView?

When you select multiple nodes of a JvTreeView, and then try to drag these nodes, the JvTreeView selects the node you clicked to drag, rather than initiating dragging all the selected nodes. You end up dragging only this single node.
Is it possible to drag multiple nodes in a JvTreeView? I am using Delphi 2007.
UPDATE: Oddly enough, if I hold down CTRL+SHIFT when dragging the items, I can successfully drag them all. Any ideas?
Suppose MultiSelectStyle is the default [msControlSelect], then the answer to your question is 'you don't release the control key when you're selecting the last item and beginning dragging'.
The culprit is in TJvTreeView.WMLButtonDown in JvComCtrls.pas. Code there tests if 'Ctrl' is pressed when the TreeView is MultiSelect, and clears all items and selects the clicked item if 'Ctrl' is not pressed. It should instead test if the clicked item is already selected and do nothing if it is.
You can see the broken behavior without dragging. Multi select a few items and then click a selected item with the mouse. The VCL TreeView do not select or de-select anything, while the JVTreeView, instead, de-selects all items and selects the clicked one.
Yes absolutely, I do it all the time.
Of course Multi-Select needs to be True and you may need to have a look at the TTreeView's MultiSelectStyle. That controls what type of nodes can be selected at the same time. For example if msSiblingOnly is set to true, you can only select sibblings.
Are you using dmAutomatic or dmManual. If the latter, it could be that you are doing something in the OnMouse* events that is negating the multi-selection you made earlier.

Resources