[Scummvm-git-logs] scummvm master -> 387b8da53b0cf6028e502876a8a69e713d5f2d04

eriktorbjorn noreply at scummvm.org
Mon Nov 20 18:41:50 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
387b8da53b SCUMM: Implement up/down arrow in Mac list box widget


Commit: 387b8da53b0cf6028e502876a8a69e713d5f2d04
    https://github.com/scummvm/scummvm/commit/387b8da53b0cf6028e502876a8a69e713d5f2d04
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2023-11-20T19:41:32+01:00

Commit Message:
SCUMM: Implement up/down arrow in Mac list box widget

Changed paths:
    engines/scumm/gfx_mac.cpp
    engines/scumm/gfx_mac.h


diff --git a/engines/scumm/gfx_mac.cpp b/engines/scumm/gfx_mac.cpp
index 99486091531..3f358463e89 100644
--- a/engines/scumm/gfx_mac.cpp
+++ b/engines/scumm/gfx_mac.cpp
@@ -1719,6 +1719,49 @@ void MacGui::MacListBox::handleWheel(int distance) {
 	}
 }
 
+bool MacGui::MacListBox::handleKeyDown(Common::Event &event) {
+	if (_texts.size() <= 1 || !_textWidgets[0]->isEnabled())
+		return false;
+
+	if (event.kbd.flags & (Common::KBD_CTRL | Common::KBD_ALT | Common::KBD_META))
+		return false;
+
+	int oldValue = _value;
+
+	switch (event.kbd.keycode) {
+	case Common::KEYCODE_UP:
+		_value = MAX(_value - 1, 0);
+		break;
+
+	case Common::KEYCODE_DOWN:
+		_value = MIN<int>(_value + 1, _texts.size() - 1);
+		break;
+
+	default:
+		break;
+	}
+
+	if (_value != oldValue) {
+		int sliderValue = _slider->getValue();
+		int pageSize = _slider->getPageSize();
+		int newSliderValue = sliderValue;
+
+		if (_value < sliderValue)
+			newSliderValue = _value;
+		else if (_value >= sliderValue + pageSize)
+			newSliderValue = _value - pageSize + 1;
+
+		if (sliderValue != newSliderValue) {
+			_slider->setValue(newSliderValue);
+			_slider->redrawHandle(sliderValue, newSliderValue);
+		}
+
+		updateTexts();
+	}
+
+	return false;
+}
+
 // ---------------------------------------------------------------------------
 // Dialog window
 //
diff --git a/engines/scumm/gfx_mac.h b/engines/scumm/gfx_mac.h
index 75152bdfa6b..08f2eac1ede 100644
--- a/engines/scumm/gfx_mac.h
+++ b/engines/scumm/gfx_mac.h
@@ -459,6 +459,7 @@ public:
 		void handleMouseHeld();
 		void handleWheelUp();
 		void handleWheelDown();
+		bool handleKeyDown(Common::Event &event);
 	};
 
 	class MacDialogWindow {




More information about the Scummvm-git-logs mailing list