double-click on "uilistbox" App designer

Hallop everyone,
How can I execute a double-click on ListBox in App Designer?
Thank you in Advance

Antworten (2)

Kevin Chng
Kevin Chng am 23 Jan. 2020
Bearbeitet: Kevin Chng am 23 Jan. 2020

1 Stimme

Up to R2019b, app designer don’t have this feature,
It is because if you click on the selected item, no event will be triggered. Therefore, we could say only single click is allowed under this limitaion.
You can use button to replace list box. [toggle button group will behave same as list box, so you could not use this], use the 'normal' button for this.
For example :
Step 1 : For example : 3 selection: Create 3 button
1.jpg
Step 2 : Create callback function for each of them (it is a bit tedious, I have 3 button, then I have 3 callback function)
2.jpg
Step 3: Create private function click
3.jpg
Step 4 : here you go:
(Single Click the button, it turns blue)
4.jpg
(Double Click the button, it turns red)
5.jpg
You might have further question about ‘how’and ‘where’ could you put your algorithm:
You could put your algorithm in the click function
6.jpg
Chidvi Modala
Chidvi Modala am 18 Jul. 2019

0 Stimmen

In guide, To make the double-click work you only need to write the code below in List box callback
function listbox_Callback(hObject, eventdata, handles)
if strcmp(get(gcf,'selectiontype'),'open')
% here you write write code, which you wanna be executed afer double-click
end
In App designer, associate the below function with ValueChangedFcn callback of the List Box.
function clickcallback(obj,evt)
persistent chk
if isempty(chk)
chk = 1;
pause(0.5); %Add a delay to distinguish single click from a double click
if chk == 1
fprintf(1,'\nI am doing a single-click.\n\n');
chk = [];
end
else
chk = [];
fprintf(1,'\nI am doing a double-click.\n\n');
end

8 Kommentare

joe
joe am 19 Jul. 2019
Hi Chidvi Modal,
I've already tried that code for App designer but it doesn't work.
the code works like this: the second click must be on a different item as the first.
so I want to click on the same item double-click.
the function "ValueChangedFcn " will not react , if the same item tweece clicked because of the value (in this case second item) doesn't changed.
but for GUIDE your code works properly.
Thank you in Advance #Chidvi Modala
KAI LUO
KAI LUO am 5 Nov. 2019
I have a similar problem. Have you solved this problem?
minlei qin
minlei qin am 6 Nov. 2019
Hello, I also encountered the same problem, after trying the above code can only achieve a second click must be different from the first click. So I want to double-click on the same item, how do I solve it?
This problem can be solved by reset the value of the listbox after the first call. Here is the modified version
function clickcallback(obj,evt)
persistent chk
if isempty(chk)
chk = 1;
pause(0.5); %Add a delay to distinguish single click from a double click
tempValue = app.FileListBox.Value;% if you want to use this value later
app.FileListBox.Value = {};
if chk == 1
fprintf(1,'\nI am doing a single-click.\n\n');
chk = [];
app.FileListBox.Value = tempValue;
end
else
chk = [];
fprintf(1,'\nI am doing a double-click.\n\n');
end
Markus Leuthold
Markus Leuthold am 12 Apr. 2020
What I don't understand is why such an ugly workaround is needed now that the App Designer was written from scratch. Why didn't Mathworks add callbacks for mouse button pressing/clicking/double-clicking like e.g Qt is doing? These kind of callbacks are needed to do a halfway serious app. It's a pity Mathworks missed this unique chance to really cleanup the mess from GUIDE.
Chidvi Modala
Chidvi Modala am 13 Apr. 2020
I have heard that this issue is known and the concerned parties may be investigating further.
Brett Mther
Brett Mther am 26 Sep. 2020
This solution doesn't work for my application. If I double click on a ListBoxItem that is already selected, the ValueChangedFcn callback doesn't fire.
Ahmet Gökhan POYRAZ
Ahmet Gökhan POYRAZ am 19 Mär. 2021
@Brett Mther it doesn't work for my application too.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018b

Gefragt:

joe
am 11 Jul. 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by