Disable windowkeypressfcn when specific child is on focus (app designer)
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Is there a way to disable windowkeypressfcn when a specific child is on focus
For example,
I have a slider and an edit box and created a windowkeypressfcn to allow me to change the slider value by pressing left and rightarrow button.
I want the slider stay in place while user is adding input into the editbox.
Any ideas?
3 Commenti
Ned
il 20 Set 2019
I suggest you make an addition to the winkdowkeypressfcn where it stops controlling the slide object after a certain key combo has been entered. You can have it reactivate on the same, or another key combo.
Gotta love some of the gymnastics required to use App designer.
Risposte (1)
Walter Roberson
il 19 Set 2019
foo = uicontrol('style','slider', 'min', 0, 'max', 1);
foo.Callback = @(hObject, event) fprintf('slider %g gco %g\n', double(hObject), double(gco))
fig = gcf;
fig.WindowKeyPressFcn = @(hObject, event) fprintf('keypressfcn %g gco %g\n', double(hObject), double(gbo));
WIth the above, the behavior is:
- type outside of the slider: keypressfcn fires and hObject and gco both show up as 1 (the figure number)
- type inside the slider when the last item clicked was the arrows of the slider: keypressfcn fires and hObject shows the figure 1 and gco shows the ID of the slider
- type inside the slider when the last item clicked was inside the slider: keypressfcn fires and hObject shows the figure 1 and gco shows the ID of the slider (this is the same behavior as above)
- click on the arrows on the slider when the last item clicked or typed on was the figure: slider callback fires and hObject shows the ID of the slider and gco shows 1 (the figure number)
- click on the arrows on the slider when the last item clicked (other than the arrows) or typed on, was inside the slider: slider callback fires and hObject shows the ID of the slider and gco shows the id of the slider
- click on the arrows of the slider when you have not yet typed on the slider after the figure was in focus, and your clicks on the slider (if any() have been restricted to the arrows of the slider rather than inside the slider: slider callback fires and hObject shows the ID of the slider and gco shows the id of the figure.
To phrase this a different way: when you type, the underlying object is brought into focus and becomes gco but hObject is the figure against which the keypressfcn is registered. When you click on the arrows of the slider when the focus is the figure, then slider callback fires, focus of the figure is not given up and hObject is the slider but gco is the figure. When you click on the arrows of the slider when the focus is on the slider because you either clicked or typed in the slider, then slider callback fires, hObject is the slider and so is gco. When you click insider the slider, then slider callback fires, hObject is the slider and so is gco.
In every case where you type over the arrows or any other part of the slider, then although hObject of the keypressfcn is the figure, gco is the slider.
Therefore you can detect the focus being the slider by checking that gco is the slider; more generally that hObject is not the same as gco (but that would include anything else that the user accidentally typed on while hovering over.)
14 Commenti
Walter Roberson
il 20 Set 2019
Not exactly. Those functions were never supported with uifigures: that documentation is saying that as of R2017b, the supported functionality for uifigures has increased to support most things with those notable exemptions. uifigures started out not supporting much.
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!