Skip to content

Commit

Permalink
Bug fix: Accelerator keys captured when editing text
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Oct 19, 2019
1 parent 41fbd91 commit 048120d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/license.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

</head>
<body alink="#fff000" link="#fff000" vlink="#fff000">
<!-- LICENCE_START -->Version: 3.191016 (16-Oct-2019)<br>
<!-- LICENCE_START -->Version: 3.191019 (19-Oct-2019)<br>
<span style="font-style: italic;">COPYRIGHT &copy; 2000-2019
USC &amp; McGill University.<br>
</span>
Expand Down
2 changes: 1 addition & 1 deletion doc/version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
% Brainstorm
% v. 3.191016 (16-Oct-2019)
% v. 3.191019 (19-Oct-2019)
30 changes: 25 additions & 5 deletions toolbox/gui/panel_record.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
gui_component('MenuItem', jMenu, [], 'Delete group', IconLoader.ICON_EVT_TYPE_DEL, [], @(h,ev)bst_call(@EventTypeDel));
gui_component('MenuItem', jMenu, [], 'Rename group', IconLoader.ICON_EDIT, [], @(h,ev)bst_call(@EventTypeRename));
gui_component('MenuItem', jMenu, [], 'Set color', IconLoader.ICON_COLOR_SELECTION, [], @(h,ev)bst_call(@EventTypeSetColor));
jItem = gui_component('MenuItem', jMenu, [], 'Show/hide group', IconLoader.ICON_DISPLAY, [], @(h,ev)bst_call(@EventTypeToggleVisible));
jItem = gui_component('MenuItem', jMenu, [], 'Show/hide group', IconLoader.ICON_DISPLAY, [], @(h,ev)CallWithAccelerator(@EventTypeToggleVisible));
jItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, 0));
gui_component('MenuItem', jMenu, [], 'Mark group as bad', IconLoader.ICON_BAD, [], @(h,ev)bst_call(@EventTypeSetBad));
jMenu.addSeparator();
Expand All @@ -170,15 +170,15 @@
jMenu.addSeparator();
gui_component('MenuItem', jMenu, [], 'Edit keyboard shortcuts', IconLoader.ICON_KEYBOARD, [], @(h,ev)gui_show('panel_raw_shortcuts', 'JavaWindow', 'Event keyboard shortcuts', [], 1, 0, 0));
jMenu.addSeparator();
jItem = gui_component('MenuItem', jMenu, [], 'Add / delete event', IconLoader.ICON_EVT_OCCUR_ADD, [], @(h,ev)bst_call(@ToggleEvent));
jItem = gui_component('MenuItem', jMenu, [], 'Add / delete event', IconLoader.ICON_EVT_OCCUR_ADD, [], @(h,ev)CallWithAccelerator(@ToggleEvent));
jItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, 0));
jItem = gui_component('MenuItem', jMenu, [], '<HTML>Edit notes&nbsp;&nbsp;&nbsp;<FONT color="#A0A0A"><I>Double-click</I></FONT>', IconLoader.ICON_EDIT, [], @(h,ev)bst_call(@EventEditNotes));
jItem = gui_component('MenuItem', jMenu, [], 'Reject time segment', IconLoader.ICON_BAD, [], @(h,ev)bst_call(@RejectTimeSegment));
jItem = gui_component('MenuItem', jMenu, [], 'Reject time segment', IconLoader.ICON_BAD, [], @(h,ev)CallWithAccelerator(@RejectTimeSegment));
jItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, 0));
jMenu.addSeparator();
jItem = gui_component('MenuItem', jMenu, [], 'Jump to previous event', IconLoader.ICON_ARROW_LEFT, [], @(h,ev)bst_call(@JumpToEvent, 'leftarrow'));
jItem = gui_component('MenuItem', jMenu, [], 'Jump to previous event', IconLoader.ICON_ARROW_LEFT, [], @(h,ev)CallWithAccelerator(@JumpToEvent, 'leftarrow'));
jItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.SHIFT_MASK));
jItem = gui_component('MenuItem', jMenu, [], 'Jump to next event', IconLoader.ICON_ARROW_RIGHT, [], @(h,ev)bst_call(@JumpToEvent, 'rightarrow'));
jItem = gui_component('MenuItem', jMenu, [], 'Jump to next event', IconLoader.ICON_ARROW_RIGHT, [], @(h,ev)CallWithAccelerator(@JumpToEvent, 'rightarrow'));
jItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.SHIFT_MASK));
% Artifacts
jMenu = gui_component('Menu', jMenuBar, [], 'Artifacts', IconLoader.ICON_MENU, [], [], 11);
Expand Down Expand Up @@ -371,6 +371,23 @@ function ListOccur_ClickCallback(h, ev)
end
end
end

%% ===== CALL WITH ACCELERATORS =====
function CallWithAccelerator(varargin)
% Make sure tree items are not being renamed
ctrl = bst_get('PanelControls', 'protocols');
if isempty(ctrl) || isempty(ctrl.jTreeProtocols) || ctrl.jTreeProtocols.isEditing()
return;
end
% Make sure the item search box is not active
ctrl = bst_get('BstControls');
if isempty(ctrl) || isempty(ctrl.jTextFilter) || ctrl.jTextFilter.hasFocus()
disp('cancel')
return;
end
% Transfer call to bst_call
bst_call(varargin{:});
end
end


Expand Down Expand Up @@ -2120,6 +2137,9 @@ function EventTypesSort(SortMode)
% USAGE: [sEvent, iOccur] = EventOccurAdd(iEvent=[selected], channelNames=[])
function [sEvent, iOccur] = EventOccurAdd(iEvent, channelNames)
global GlobalData;
% Initialize returned variables
sEvent = [];
iOccur = [];
% Parse inputs
if (nargin < 2) || isempty(channelNames) || ~iscell(channelNames)
channelNames = [];
Expand Down

0 comments on commit 048120d

Please sign in to comment.