Skip to content

Commit

Permalink
Merge pull request #923 from OpenGeoscience/fix-annotation-key-handler
Browse files Browse the repository at this point in the history
Fix an issue with key handling.
  • Loading branch information
manthey authored Sep 6, 2018
2 parents 0c72696 + 41b3976 commit 9bd9124
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Bug Fixes
- Fixed an issue with the annotation key handler (#923)

## Version 0.18.0

### Features
Expand Down
13 changes: 10 additions & 3 deletions src/annotationLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ var annotationLayer = function (args) {
m_annotations = [],
m_features = [],
m_labelFeature,
m_labelLayer;
m_labelLayer,
m_keyHandler;

var geojsonStyleProperties = {
'closed': {dataType: 'boolean', keys: ['closed', 'close']},
Expand Down Expand Up @@ -519,10 +520,13 @@ var annotationLayer = function (args) {
mapNode = m_this.map().node(), oldMode = m_mode;
m_mode = arg;
mapNode.toggleClass('annotation-input', !!(m_mode && m_mode !== m_this.modes.edit));
if (!m_keyHandler) {
m_keyHandler = Mousetrap(mapNode[0]);
}
if (m_mode) {
Mousetrap(mapNode[0]).bind('esc', function () { m_this.mode(null); });
m_keyHandler.bind('esc', function () { m_this.mode(null); });
} else {
Mousetrap(mapNode[0]).unbind('esc');
m_keyHandler.unbind('esc');
}
if (m_this.currentAnnotation) {
switch (m_this.currentAnnotation.state()) {
Expand Down Expand Up @@ -1150,6 +1154,9 @@ var annotationLayer = function (args) {
* @returns {this} The current layer.
*/
this._exit = function () {
if (m_keyHandler) {
m_keyHandler.reset();
}
m_this._removeLabelFeature();
// Call super class exit
s_exit.call(m_this);
Expand Down

0 comments on commit 9bd9124

Please sign in to comment.