MATLAB Answers

double-click on "uilistbox" App designer

38 ビュー (過去 30 日間)
joe
joe 2019 年 7 月 11 日
コメント済み: Chidvi Modala 2020 年 4 月 13 日
Hallop everyone,
How can I execute a double-click on ListBox in App Designer?
Thank you in Advance

  0 件のコメント

Sign in to comment.

回答 (2 件)

Chidvi Modala
Chidvi Modala 2019 年 7 月 18 日
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

  6 件のコメント

表示 3 件の古いコメント
Huy Dinh Quang
Huy Dinh Quang 2019 年 11 月 10 日
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 2020 年 4 月 12 日
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 2020 年 4 月 13 日
I have heard that this issue is known and the concerned parties may be investigating further.

Sign in to comment.


Kevin Chng
Kevin Chng 2020 年 1 月 23 日
編集済み: Kevin Chng 2020 年 1 月 23 日
Up to R2019b, app designer dont 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 ‘howand where could you put your algorithm:
You could put your algorithm in the click function
6.jpg

  0 件のコメント

Sign in to comment.

Categories

製品


リリース

R2018b

Translated by