Loading @GUI/textbox_callback.m +16 Changes for @GUI/textbox_callback.m: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -39,6 +39,21 @@ if(~isempty(unicode2native(event.Character))) % hack because api does not update the string field of % textbox until after it loses focus. temporarily focus on % label, read string, refocus on textbox. % When we temporarily lose focus, we would want to save the cursor % position so we can return to the cursor position were we left of. % The cursor position is a uicontrol property that is not exposed by % Matlab. Since all Matlab uicontrols are based on underlying Java % Swing controls, accessing these features is possible via their % Java control peers. % the findobj function finds java objects contained within a specified % Matlab GUI handle java_obj = findjobj(src); java_obj = java_obj.getComponent(0).getComponent(0); Cursor_Pos = java_obj.getCaretPosition(); uicontrol(object.name_label); undo_data.action = 1; Loading @@ -50,6 +65,7 @@ if(~isempty(unicode2native(event.Character))) object.undo_man.new_state(undo_data); uicontrol(src); java_obj.setCaretPosition(Cursor_Pos); figure(object.fig); object.update_undoredo; Loading FindJavaObjects/findjobj.m +3456 File added.Preview size limit exceeded, changes collapsed. Show changes FindJavaObjects/findjobj_fast.m +60 Changes for FindJavaObjects/findjobj_fast.m: 60 added lines, 0 removed lines. Original line number Diff line number Diff line function jControl = findjobj_fast(hControl, jContainer) try jControl = hControl.getTable; return, catch, end % fast bail-out for old uitables try jControl = hControl.JavaFrame.getGUIDEView; return, catch, end % bail-out for HG2 matlab.ui.container.Panel oldWarn = warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame'); if nargin < 2 || isempty(jContainer) % Use a HG2 matlab.ui.container.Panel jContainer if the control's parent is a uipanel try hParent = get(hControl,'Parent'); catch % Probably indicates an invalid/deleted/empty handle jControl = []; return end try jContainer = hParent.JavaFrame.getGUIDEView; catch, jContainer = []; end end if isempty(jContainer) hFig = ancestor(hControl,'figure'); jf = get(hFig, 'JavaFrame'); jContainer = jf.getFigurePanelContainer.getComponent(0); end warning(oldWarn); jControl = []; counter = 20; % 2018-09-21 speedup (100 x 0.001 => 20 x 0.005) - Martin Lehmann suggestion on FEX 2016-06-07 specialTooltipStr = '!@#$%^&*'; try % Fix for R2018b suggested by Eddie (FEX comment 2018-09-19) tooltipPropName = 'TooltipString'; oldTooltip = get(hControl,tooltipPropName); set(hControl,tooltipPropName,specialTooltipStr); catch tooltipPropName = 'Tooltip'; oldTooltip = get(hControl,tooltipPropName); set(hControl,tooltipPropName,specialTooltipStr); end while isempty(jControl) && counter>0 counter = counter - 1; pause(0.005); jControl = findTooltipIn(jContainer, specialTooltipStr); end set(hControl,tooltipPropName,oldTooltip); try jControl.setToolTipText(oldTooltip); catch, end try jControl = jControl.getParent.getView.getParent.getParent; catch, end % return JScrollPane if exists end function jControl = findTooltipIn(jContainer, specialTooltipStr) try jControl = []; % Fix suggested by H. Koch 11/4/2017 tooltipStr = jContainer.getToolTipText; %if strcmp(char(tooltipStr),specialTooltipStr) if ~isempty(tooltipStr) && tooltipStr.startsWith(specialTooltipStr) % a bit faster jControl = jContainer; else for idx = 1 : jContainer.getComponentCount jControl = findTooltipIn(jContainer.getComponent(idx-1), specialTooltipStr); if ~isempty(jControl), return; end end end catch % ignore end end Loading
@GUI/textbox_callback.m +16 Changes for @GUI/textbox_callback.m: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -39,6 +39,21 @@ if(~isempty(unicode2native(event.Character))) % hack because api does not update the string field of % textbox until after it loses focus. temporarily focus on % label, read string, refocus on textbox. % When we temporarily lose focus, we would want to save the cursor % position so we can return to the cursor position were we left of. % The cursor position is a uicontrol property that is not exposed by % Matlab. Since all Matlab uicontrols are based on underlying Java % Swing controls, accessing these features is possible via their % Java control peers. % the findobj function finds java objects contained within a specified % Matlab GUI handle java_obj = findjobj(src); java_obj = java_obj.getComponent(0).getComponent(0); Cursor_Pos = java_obj.getCaretPosition(); uicontrol(object.name_label); undo_data.action = 1; Loading @@ -50,6 +65,7 @@ if(~isempty(unicode2native(event.Character))) object.undo_man.new_state(undo_data); uicontrol(src); java_obj.setCaretPosition(Cursor_Pos); figure(object.fig); object.update_undoredo; Loading
FindJavaObjects/findjobj.m +3456 File added.Preview size limit exceeded, changes collapsed. Show changes
FindJavaObjects/findjobj_fast.m +60 Changes for FindJavaObjects/findjobj_fast.m: 60 added lines, 0 removed lines. Original line number Diff line number Diff line function jControl = findjobj_fast(hControl, jContainer) try jControl = hControl.getTable; return, catch, end % fast bail-out for old uitables try jControl = hControl.JavaFrame.getGUIDEView; return, catch, end % bail-out for HG2 matlab.ui.container.Panel oldWarn = warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame'); if nargin < 2 || isempty(jContainer) % Use a HG2 matlab.ui.container.Panel jContainer if the control's parent is a uipanel try hParent = get(hControl,'Parent'); catch % Probably indicates an invalid/deleted/empty handle jControl = []; return end try jContainer = hParent.JavaFrame.getGUIDEView; catch, jContainer = []; end end if isempty(jContainer) hFig = ancestor(hControl,'figure'); jf = get(hFig, 'JavaFrame'); jContainer = jf.getFigurePanelContainer.getComponent(0); end warning(oldWarn); jControl = []; counter = 20; % 2018-09-21 speedup (100 x 0.001 => 20 x 0.005) - Martin Lehmann suggestion on FEX 2016-06-07 specialTooltipStr = '!@#$%^&*'; try % Fix for R2018b suggested by Eddie (FEX comment 2018-09-19) tooltipPropName = 'TooltipString'; oldTooltip = get(hControl,tooltipPropName); set(hControl,tooltipPropName,specialTooltipStr); catch tooltipPropName = 'Tooltip'; oldTooltip = get(hControl,tooltipPropName); set(hControl,tooltipPropName,specialTooltipStr); end while isempty(jControl) && counter>0 counter = counter - 1; pause(0.005); jControl = findTooltipIn(jContainer, specialTooltipStr); end set(hControl,tooltipPropName,oldTooltip); try jControl.setToolTipText(oldTooltip); catch, end try jControl = jControl.getParent.getView.getParent.getParent; catch, end % return JScrollPane if exists end function jControl = findTooltipIn(jContainer, specialTooltipStr) try jControl = []; % Fix suggested by H. Koch 11/4/2017 tooltipStr = jContainer.getToolTipText; %if strcmp(char(tooltipStr),specialTooltipStr) if ~isempty(tooltipStr) && tooltipStr.startsWith(specialTooltipStr) % a bit faster jControl = jContainer; else for idx = 1 : jContainer.getComponentCount jControl = findTooltipIn(jContainer.getComponent(idx-1), specialTooltipStr); if ~isempty(jControl), return; end end end catch % ignore end end