tagcompletion like stackoverflow - jquery-ui

Working example
Bug
add an item that exists in the list
add an item that doesn't exist in the list
add an item that exists in the list by clicking arrow key or clicking an item with mouse
notice that all items are erased and everything starts over.
I am building this on top of a solution provided to me in another question. I've taken the code from that example and modified to my needs. however, now I am having the issue stated above.
What can I do to avoid having the list erase all items when a new item is added by clicking down arrow key after a non existent item is added.

Add the following to the options object you pass the autocomplete widget:
focus: function() { return false; }
From the docs on focus:
Canceling this event prevents the
value from being updated, but does not
prevent the menu item from being
focused.
Here's your example without the bug: http://jsbin.com/oquda3/4

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.

Drag and Drop: by using copyArrayItem() the dragged item should not be removed from start array while drop Angular 8

I have a list of items from where I drag an item and drop it into another list. I'm using copyArrayItem() method from Angular to not remove the item from the previous array.
I start dragging, the item is within the previous array: the placeholder from that item shows up.
Start dragging, placeholder shows up
I'm leaving the previous array: the placeholder/dragged item disappears (I want that the placeholder/dragged item stays) -> the start array has minus 1 items.
Placeholder disappears, what I don't want
I'm on the target array: a placeholder appears in a target array.
I'm dropping the item: item appears now in the start and target array.
After more research I've found an open issue about that problem:
https://github.com/angular/components/issues/13906
and there I've found suggestions from participants:
https://stackblitz.com/edit/angular-krmecd?file=src%2Fapp%2Fapp.component.ts
This example with workaround helped me to solve this problem:
https://stackblitz.com/edit/angular-o8exzv-jauhhi?file=src%2Fapp%2Fcdk-drag-drop-connected-sorting-example.html
Maybe this information will be useful for someone.

What event to call when ListView selected item changed?

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.

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);

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