Disable pointer event in App Designer
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I created an app with app designer that allows to insert data for energetic assets. When the user changes a value on the front end, this value is saved on a database (structure). This callback may be long ... so during its execution I would like to avoid any further editing on the front end.
I have already tried:
- uiprogressdlg: not bad because it makes all the app disable so the user cannot change anything until the end of the callback.
- change Interruptible properties to false and BusyAction to cancel: in this case the new callback is deleted but the user can still change the value on the front end, then the value he sees is different from the value in the database behind.
Therefore, I am thinking that the best way is to prevent any actions from the mouse and keyboard during the execution of a callback. Is there a way to stop pointer event on app designer?
Actually changing the pointer shape to watch is nice but useless because the user can still select an editfield on the app.
채택된 답변
To temporarily disable interaction across the entire app, use uiprogressdlg. It sounds like this is too restrictive for your needs.
uipd = uiprogressdlg(app.eyeTrackingReformatUIFigure,'Title','App busy','Indeterminate','on');
% STUFF THAT MAKES ME WAIT GOES HERE
close(startupUIProg)
To temporarily disable interactions for a subset of app components, create a function that recieves a binary flag that enables/disables a set of components.
To toggle the enable/disable properties, call
toggleFileSelection(app, 'off') % disables
% STUFF THAT MAKES ME WAIT GOES HERE
toggleFileSelection(app, 'on') % enables
The toggleFileSelection function merely lists components and sets their enable value. If you want to control an bunch of objects within the same vicinity, consider placing them within a uipanel and then you can toggle the panel instead of listing all of the objects.
function toggleFileSelection(app, state)
% state is true|false or 'on'|'off' to enable|disable components
app.AddfilesButton.Enable = state;
app.UndoButton.Enable = state;
app.SelectedFilesListBox.Enable = state;
app.filesettingsMenu.Enable = state;
app.GeneralfilesettingsMenu.Enable = state;
app.SetoutputfiletagMenu.Enable = state;
end
댓글 수: 9
Thank you Adam.
Your second solution may work. I saw online the java.awt.Robot function ... do you know if it is possible throught java?
I've used the second suggestion in my answer for several apps. It's clean and it achieves your ultimate goal. It's better than disabling a pointer because when app components are disabled, their appearance clearly indicates they are disabled. When a cursor disappears, people may think something's wrong.
I've used a java robot to simulate keystrokes and mouse movements and it took some finessing. In the end, it was clumsy and I had to be very careful to not let it interact with other programs. I don't think it's a good solution for the goal.
Another idea I had that I haven't tried am not entirely certain will work is that you could create a custom cursor that's a single pixel (or maybe even no pixels, I haven't tried it). You could set the cursor to this "empty cursor" and then replace it with the default cursor as needed. However, I think the user could still click on stuff if the cursor happens to be on top of a UI component. Scroll down to "part 3" in this Community Highlight to learn how to make your own cursor.
I was looking for a Java class to disable the listener of the mouse temporarily but I guess it is not accessible within Matlab.
The empty cursor does not fit with my goal because the orignal idea was to disable the click and change the form of the cursor to watch like "ehi user I am working wait!"
I can do this with the enable property and the watch cursor. But to be honest I do not really like the fact that the editfield goes blurry because if the pc is enough powerful and the RAM is ok, then this process may last for 1/2 seconds ... and the user does not have the time to change something else ... the problem is when the pc is stuck and the app needs more time.
> I was looking for a Java class to disable the listener of the mouse temporarily but I guess it is not accessible within Matlab.
I'm not recommending you do this but I know simulated mouse movement is possible with a java robot. I suppose one could detect when the cursor is about to enter an app component and the prevent the mouse from entering that component by deflecting its position. But it would be really ugly and the user would probably think they have a virus.
> I do not really like the fact that the editfield goes blurry because if the pc is enough powerful and the RAM is ok, then this process may last for 1/2 seconds ... and the user does not have the time to change something else
I don't understand this part. The two edit fields on the right are disabled and the two on the left and enabled. Neither are blurry. They disabled ones are faded but I can still read the content. I didn't understand the part about fast and slow computers. Toggling the enable property takes microseconds.

Another idea is that many fields, including edit fields, have an "editable" property that you could toggle.
I used the wrong word ... it is not blurry but faded, sorry.
ABout the slow computers, think about the code between set(listProp,'enable','off') and set(listProp,'enable','on'). If the code takes some seconds to performe the script, then the user will wait with faded elements on the UI. Anyway it is a matter of taste!
Thanks for your help!
> ...then the user will wait with faded elements on the UI
But I thought the goal was to prevent the user from interacting with those component during that period? This would only be applied to those select components. Maybe I didn't understand the goal.
>Thanks for your help!
My pleasure.
No Adam you got the goal totally, I would have liked to make the user wait without fading the component!
I see. There should be some kind of visual indicator as to why they can't interact with the component but I suppose as they become familiar with the app they will learn what they can can't do.
The editboxes have an editable property that you can toggle without changing the visual appearance of the editbox but I don't think all components have that. Other than that, I'm out of ideas 🧐
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
