how to keep listbox item selected state? - listbox

global SelectMode
set SelectMode mode1
set FunList {Func1 Func2 Func3}
listbox .lb -listvariable FunList
bind .lb <<ListboxSelect>> {puts [.lb curselection]}
ttk::combobox .com -values {mode1 mode2 mode3} -textvariable SelectMode
pack .lb
pack .com
when I first select the item (choose "Func2" as example) in the listbox and then select the mode in the combobox, then I get an unexpected empty string output like below:
1
"" (unneeded)
how to keep the listbox item selected state and unaffected by the combobox? Thanks

The .lb curselection command leverages the window manager focus to know what is selected. Since the window manager is busy with another element (the combobox in this case), it can't see that the listbox has a selection. The solution is to write a procedure to keep track of the listbox selection. And update a variable when the selection is changed.
global SelectMode
lb_selection = ""
set SelectMode mode1
set FunList {Func1 Func2 Func3}
listbox .lb -listvariable FunList
bind .lb <<ListboxSelect>> {ListSelectionChanged %W}
ttk::combobox .com -values {mode1 mode2 mode3} -textvariable SelectMode
pack .lb
pack .com
# Procedure bound to <<ListboxSelect>> virtual event.
proc ListSelectionChanged { listbox } {
global lb_selection
set lb_selection [$listbox curselection]
}
# Procedure to repeatedly print the selection status of the listbox
proc printLBSelection { } {
global lb_selection
puts $lb_selection
after 2000 printLBSelection
}

You can set the exportselection option to false to prevent the selection from changing when a different widget has a selection.
listbox .lb -listvariable FunList -exportselection false

Related

Vaadin flow select component prevent click event propagation to grid header

In Vaadin Flow 23.1.x we have a grid with different filter fields in the header.
In the screen below the "Vendorstatus" is a ComboBox and the ValudateCode is a Select component.
What we now see:
If we click in the Vedonrstatus field, the dropdown opens and nothing else happens, which is ok
If we click in the ValutaCode field, the dropdown opens too, but also the "Sort" of the grid is triggered.
So it looks like the select component does not consume/block the ClickEvent from propagating down to the parent components.
Is there a way to prevent the click to trigger the sort of the column grid?
Workarround would be to re-implement my Select based header filter with ComboBox type ones.
The code to generate the filter header:
headerRow.getCell(col).setComponent(createSelectFilter(...));
And the createSelectFilter method:
private static Component createSelectFilter(...) {
VerticalLayout vl= new VerticalLayout();
Label l= new Label("Headername");
vl.add(l);
Select<MyobjClass> select= new Select<>();
select.setItems(...);
select.getElement().addEventListener("click",
event -> {})
.addEventData("event.stopPropagation()");
select.addValueChangeListener( e --> updateDataFilter());
vl add(select);
return vl;
}
This does not stop propagation of the click to open the dropdown and select a value to also trigger a sort "command" on that column
You must use this method to add the listener them you can
select.getElement().addEventListener("click",
event -> ...)
.addEventData("event.stopPropagation()");

Screen reader(NVDA) is not reading pre-selected value and expanded/collapsed state of mat-select

NVDA is not reading collapse/expanded state of mat-select also it is not reading pre-selected value
use an aria-expanded attribute for reading collapse/expanded state. you can update the value to true when the dropdown panel opens.
<mat-select (openedChange)="isExpanded = $event" [attr.aria-expanded]="isExpanded">
You can use the panelOpen property of the select's local variable
<mat-select #myselect [attr.aria-expanded]="myselect.panelOpen">

get selected item from kendo treeview in javascript

I'm trying to get the selected item with a specific id from outside of the kendo treeview. Basically, I'm writing a js function to try to find out which node is selected. Is there a way to find out which node (and it's datasource properties) can be extracted?
I can get the node data if the an event listener passes the event but can't figure out a way to get to that node without the event listener.
Once I get that data, I would like to update some button links to go to the next item in the node.
//get node WITH listener:
function getNode(e){
var nodedata = $('#treeName').getKendoTreeView().dataItem(e.node).id;
console.log(nodedata);
}
//BUT I want to find out from outside of Kendo treeview with something like this:
function getNode() {
var getSelectedId = $('#treeName').getKendoTreeView().getCurrentSelectedItem().id
console.log(getSelectedId);
}
It's pretty straightforward. Just use
$('#treeName').data("kendoTreeView").select().data().id

Set value on propertygrid combobox (jeasyui)

How to set value on jeasyui combobox inside propertygrid using jquery?
I tried to fire the grid using a selector, and then select the "td" where the combobox is generated, but without success.
The value of the "td" changes, but when you click on the combobox or make a post the original previous value returns
$("#datagrid-row-r4-2-3 > td:nth-child(3) > div").html('new value');
I got it, follow the code:
//update visual value on screen
$("#datagrid-row-r4-2-3 > td:nth-child(3) > div").html(row.cd_erro);
//update value
$("#pg").propertygrid('getRows')[3].value = 'new value';

Adding item to combobox in Delphi XE4 and Devexpress VCL 13.1

I have following code:
var
cbMyCombo: TcxLookupComboBox;
I have a dataset which has following query:
SELECT ID, NAME from MYTABLE;
This query works fine.
Now I have done binding in cbMyCombo in DFM file as following:
object cbMyCombo: TcxLookupComboBox
Properties.KeyFieldNames = 'ID'
Properties.ListColumns = <
item
FieldName = 'NAME'
end>
end
It works fine and combobox is binded. My problem is, nothing is selected by default. I want that initially combobox should contain "View All" option.
I am trying like this:
cbMyCombo.Text := 'View All'
But, this is not setting anything because "View All" is not the part of the list which I have binded to it. I want to manually add "View All" as FieldName and 0 as KeyFieldName and this should be selected by default. How can I do this?
You should add the 'View all', 0 row to your dataset and set the EditValue of your combobox to 0 in your intialization.

Resources