summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2017-07-25 18:44:19 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2017-07-25 18:44:19 +0000
commit463b3e5d9d1c34fee5fd3d5151f228435467f3f0 (patch)
treeb403fe1820c7e5d4234d098810765eaf68f6daa0
parent768ba675b06d9e794a1827ea2e376fe2670c5323 (diff)
Fix blocks demo keyboard handling, add new shortcut.
The blocks demo was unintentionally intercepting ctrl/+ which was introduced in FLTK 1.4.0 to change scaling for HiDPI screens. Now this is separated: use ctrl/+/-/0 to change scaling, use '+' alone to change the game level. The new keyboard shortcut ALT+SHIFT+H allows users to reset their high scores without editing the preferences file. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12354 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES4
-rw-r--r--test/blocks.cxx19
2 files changed, 20 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index c83fb7d5d..79f8a5b0d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -63,6 +63,10 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2017
Other Improvements
- (add new items here)
+ - The blocks demo program got a new keyboard shortcut (ALT+SHIFT+H) to
+ reset the user's high score. It is now slower than before in higher
+ levels, hence you can expect higher scores (due to a bug fix in the
+ timer code). You can use the '+' key to increase the level at all times.
- Some methods of Fl_Tabs are now virtual and/or protected for easier
subclassing without code duplication (STR #3211 and others).
To be continued...
diff --git a/test/blocks.cxx b/test/blocks.cxx
index 335a9aeb0..d9b86839d 100644
--- a/test/blocks.cxx
+++ b/test/blocks.cxx
@@ -751,9 +751,22 @@ int BlockWindow::handle(int event) {
switch (event) {
case FL_KEYBOARD:
- if (Fl::event_text()) {
- if (strcmp(Fl::event_text(), "+") == 0)
- up_level();
+
+ // '+': raise level
+ if (Fl::event_text() &&
+ !Fl::event_state(FL_CTRL | FL_ALT | FL_META) &&
+ !strcmp(Fl::event_text(), "+")) {
+ up_level();
+ return (1);
+ }
+
+ // ALT + SHIFT + 'H': clear highscore
+ if (Fl::event_text() &&
+ (Fl::event_state() & (FL_ALT | FL_SHIFT)) == (FL_ALT | FL_SHIFT) &&
+ !strcmp(Fl::event_text(), "H")) {
+ high_score_ = score_;
+ prefs_.set("high_score", high_score_);
+ return (1);
}
break;