From 387b61e211973ff31212c74e4f73d25c5a29070c Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Wed, 15 Jan 2020 00:13:41 +0000 Subject: [PATCH] src/GUI/MapWidget.cxx: don't pan map with cursor keys if /gui/map/key-pan is 0. Allows control of autopilot with cursor keys when map is being displayed. Default is 1, which preserves old behaviour. --- src/GUI/MapWidget.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/GUI/MapWidget.cxx b/src/GUI/MapWidget.cxx index f0d4b2848..ec7163c0e 100644 --- a/src/GUI/MapWidget.cxx +++ b/src/GUI/MapWidget.cxx @@ -500,6 +500,13 @@ void MapWidget::setProperty(SGPropertyNode_ptr prop) _root->setBoolValue("draw-data", false); _root->setBoolValue("draw-flight-history", false); _root->setBoolValue("magnetic-headings", true); + + /* If /gui/map/key-pan is undefined, fgdata's gui/dialogs/map.xml will set it + to "" when it opens map, so if we see this we change to default value of 1. + */ + if (!strcmp( _root->getStringValue("key-pan"), "")) { + _root->setIntValue("key-pan", 1); + } } void MapWidget::setSize(int w, int h) @@ -555,6 +562,16 @@ int MapWidget::checkKey (int key, int updown ) if ((updown == PU_UP) || !isVisible () || !isActive () || (window != puGetWindow())) { return FALSE ; } + + bool key_pan = _root->getIntValue("key-pan"); + if (!key_pan && (0 + || key == PU_KEY_UP + || key == PU_KEY_DOWN + || key == PU_KEY_LEFT + || key == PU_KEY_RIGHT + )) { + return FALSE; + } switch (key) {