Skip to content

Commit

Permalink
Removed lost focus logic bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GallVp committed Sep 10, 2019
1 parent 5676717 commit 01a2df0
Showing 1 changed file with 49 additions and 40 deletions.
89 changes: 49 additions & 40 deletions emgEventsManageTool.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,12 @@
vars.btnNextChannel = uicontrol('Style', 'pushbutton', 'String', '>>',...
'TooltipString', 'Next channel',...
'Position', [450 60 25 20],...
'Callback', @nextChannel,...
'KeyPressFcn', @keyPressHandler);
'Callback', @nextChannel);

vars.btnPreviousChannel = uicontrol('Style', 'pushbutton', 'String', '<<',...
'TooltipString', 'Previous channel',...
'Position', [400 60 25 20],...
'Callback', @previousChannel,...
'KeyPressFcn', @keyPressHandler);
'Callback', @previousChannel);

vars.btnReset = uicontrol('Style', 'pushbutton', 'String', 'Reset',...
'TooltipString', 'Reset events',...
Expand Down Expand Up @@ -187,6 +185,11 @@

% Handle callbacks
function next(hObject,~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');

if(vars.options.scanOnsetsOffsets)
vars.offsetNum = vars.offsetNum + 1;
else
Expand All @@ -195,13 +198,14 @@ function next(hObject,~)
vars.highlightPoint = [];
vars.selectedEvent = [];
eventScroll;
end

function previous(hObject,~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end

function previous(hObject,~)

if(vars.options.scanOnsetsOffsets)
vars.offsetNum = vars.offsetNum - 1;
else
Expand All @@ -210,13 +214,14 @@ function previous(hObject,~)
vars.highlightPoint = [];
vars.selectedEvent = [];
eventScroll;
end

function nextChannel(hObject,~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end

function nextChannel(hObject,~)

vars.channelNum = vars.channelNum + 1;
vars.highlightPoint = [];
vars.selectedEvent = [];
Expand All @@ -229,13 +234,14 @@ function nextChannel(hObject,~)
vars.offsetNum = 1;
end
updateView
end

function previousChannel(hObject,~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end

function previousChannel(hObject,~)

vars.channelNum = vars.channelNum - 1;
vars.highlightPoint = [];
vars.selectedEvent = [];
Expand All @@ -248,13 +254,14 @@ function previousChannel(hObject,~)
vars.offsetNum = 1;
end
updateView
end

function reset(hObject,~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end

function reset(hObject,~)

vars.events(vars.channelNum).onSets = vars.EMG.events(vars.channelNum).onSets;
vars.events(vars.channelNum).offSets = vars.EMG.events(vars.channelNum).offSets;
vars.onsetNum = 1;
Expand All @@ -264,10 +271,6 @@ function reset(hObject,~)
vars.numOnsets = length(vars.events(vars.channelNum).onSets);
vars.numOffsets = length(vars.events(vars.channelNum).offSets);
updateView
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end


Expand Down Expand Up @@ -302,6 +305,11 @@ function highlightEvent(~,callbackdata)
end

function delEvent(hObject, ~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');

if(~isempty(vars.highlightPoint) && strcmp(vars.selectedEvent.type, vars.EVENT_TYPE_ONSET))
vars.events(vars.channelNum).onSets(vars.selectedEvent.location...
== vars.events(vars.channelNum).onSets) = [];
Expand All @@ -325,13 +333,14 @@ function delEvent(hObject, ~)
vars.selectedEvent = [];
updateView;
end
end

function moveEvent(hObject, ~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end

function moveEvent(hObject, ~)

if(~isempty(vars.highlightPoint) && strcmp(vars.selectedEvent.type, vars.EVENT_TYPE_ONSET))
vars.events(vars.channelNum).onSets(vars.selectedEvent.location == vars.events(vars.channelNum).onSets) = [];
vars.events(vars.channelNum).onSets = sort([vars.events(vars.channelNum).onSets;round(vars.highlightPoint(1) .* vars.fs)]);
Expand All @@ -347,10 +356,6 @@ function moveEvent(hObject, ~)
vars.selectedEvent = [];
updateView;
end
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end

function axesWhiteSpaceClicked(~, ~)
Expand All @@ -360,30 +365,32 @@ function axesWhiteSpaceClicked(~, ~)
end

function instOnEvent(hObject, ~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');

if(~isempty(vars.highlightPoint))
vars.events(vars.channelNum).onSets = sort([vars.events(vars.channelNum).onSets;round(vars.highlightPoint(1) .* vars.fs)]);
vars.numOnsets = length(vars.events(vars.channelNum).onSets);
vars.highlightPoint = [];
vars.selectedEvent = [];
updateView;
end
end
function instOffEvent(hObject, ~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end
function instOffEvent(hObject, ~)

if(~isempty(vars.highlightPoint))
vars.events(vars.channelNum).offSets = sort([vars.events(vars.channelNum).offSets;round(vars.highlightPoint(1) .* vars.fs)]);
vars.numOffsets = length(vars.events(vars.channelNum).offSets);
vars.highlightPoint = [];
vars.selectedEvent = [];
updateView;
end
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end

function keyPressHandler(~, eventData)
Expand Down Expand Up @@ -497,16 +504,22 @@ function keyPressHandler(~, eventData)
end

function channelView(hObject, ~)
tempEMG = vars.EMG;
tempEMG.events = vars.events;
plotEMG(tempEMG, vars.options);
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');

tempEMG = vars.EMG;
tempEMG.events = vars.events;
plotEMG(tempEMG, vars.options);
end

function scanOnsetsOffsets(hObject, ~)
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');

if(vars.options.scanOnsetsOffsets)
vars.options.scanOnsetsOffsets = 0;
set(vars.btnScanOnsetsOffsets, 'String', 'Scan Offsets');
Expand All @@ -515,10 +528,6 @@ function scanOnsetsOffsets(hObject, ~)
set(vars.btnScanOnsetsOffsets, 'String', 'Scan Onsets');
end
eventScroll;
% To put focus back to main GUI
set(hObject, 'enable', 'off');
drawnow;
set(hObject, 'enable', 'on');
end

function updateView(retainZoom)
Expand Down

0 comments on commit 01a2df0

Please sign in to comment.