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.

 채택된 답변

Adam Danz
Adam Danz 2021년 2월 9일
편집: Adam Danz 2021년 2월 9일

0 개 추천

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?
Adam Danz
Adam Danz 2021년 2월 9일
편집: Adam Danz 2021년 2월 10일
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.
Adam Danz
Adam Danz 2021년 2월 11일
> 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!
Adam Danz
Adam Danz 2021년 2월 11일
> ...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!
Adam Danz
Adam Danz 2021년 2월 11일
편집: Adam Danz 2021년 2월 11일
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에 대해 자세히 알아보기

제품

릴리스

R2020b

태그

질문:

2021년 2월 9일

편집:

2021년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by