How can drop-down menus inside a uitable be opened with just a single mouseclick?

I have build an application using the App Designer, which is using a uitable with drop-down menus inside the columns. To open these drop-down menus I have to click twice. Once for selecing the specific cell of the table and a second time to open the drop-down list. Is there a way to prevent this and get the same result with a single mouseclick?

댓글 수: 6

Hello Stefan,
How did you created the dropdown in the uitable. I am struggling to make it work. I knew how to do it with GUIDE but fails with App.
Thanks
Hi,
just edit the ColumnFormat for that. e.g.
tableFormat = {'1','2','3','4'};
app.UITable.ColumnFormat = {tableFormat} ;
app.UITable.Data = {'1'};
Hey Stefan!
Did you find a solution to your issue? Because I am struggling with the same one...
Yes, I did. unfortunately I had to find a workaround cause there is is no official solution available yet.
I added a CellSelectionCallback to the corresponding table and on activation I perform a second mousclick via the java.awt.Robot method:
mouse = java.awt.Robot;
mouse.mousePress(java.awt.event.InputEvent.BUTTON1_MASK);
mouse.mouseRelease(java.awt.event.InputEvent.BUTTON1_MASK);
Thank you for this solution. It seema bit laggy. Is there another work around?
Hi
I am also struggling to add drop-down menu for a particular column for uitable and app designer both.
Please help.

댓글을 달려면 로그인하십시오.

답변 (1개)

Rahul
Rahul 2025년 4월 9일
편집: Rahul 2025년 4월 9일
I understand that while trying to use dropdowns inside a UITable, the dropdown opens after clicking on the cell twice, once for selecting the cell and once for opening the dropdown. This behaviour might cause delays in your workflow.
The workaround mentioned which uses a 'CellSelectionCallback' and perform a second click on the cell by using java.awt.Robot seems to be a good workaround in this case.
However as I checked, the UITable component has been improved in the recent versions of MATLAB (i.e. R2024a onwards). Now if the dropdown arrow present in the cell is clicked directly, the the dropdown would open without the need of more number of clicks. Clicking on any other part of the cell would not open the dropdown menu and would just select the cell.
Here is an example:
The following Mathworks documentations can be referred to know more:
Thanks.

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품

질문:

2018년 6월 26일

편집:

2025년 4월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by