From 751226bc6d514e7ba22784fc6a0b617109cfed4a Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Wed, 3 Jan 2024 20:13:49 -0800 Subject: [PATCH] use HotkeyLabels for hotkeys --- changelog.txt | 1 + gui/quickcmd.lua | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/changelog.txt b/changelog.txt index c6caa5555b..c79493f8bb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -46,6 +46,7 @@ Template for new versions: - `confirm`: added confirmation dialog for right clicking out of the trade agreement screen (so your trade agreement selections aren't lost) - `gui/autobutcher`: interface redesigned to better support mouse control - `gui/launcher`: now persists the most recent 32KB of command output even if you close it and bring it back up +- `gui/quickcmd`: clickable buttons for command add/remove/edit operations ## Removed diff --git a/gui/quickcmd.lua b/gui/quickcmd.lua index b4d3dcdfa6..c1e9866988 100644 --- a/gui/quickcmd.lua +++ b/gui/quickcmd.lua @@ -74,16 +74,26 @@ function QCMDDialog:init(info) text={'Command list is empty.', NEWLINE, 'Hit "A" to add one!'}, visible=function() return #self.commands == 0 end, }, - widgets.Label{ - frame={b=0, h=2}, - text={ - {key='CUSTOM_SHIFT_A', text=': Add command', - on_activate=self:callback('onAddCommand')}, ' ', - {key='CUSTOM_SHIFT_D', text=': Delete command', - on_activate=self:callback('onDelCommand')}, NEWLINE, - {key='CUSTOM_SHIFT_E', text=': Edit command', - on_activate=self:callback('onEditCommand')}, - }, + widgets.HotkeyLabel{ + frame={b=1, l=0}, + key='CUSTOM_SHIFT_A', + label='Add command', + auto_width=true, + on_activate=self:callback('onAddCommand'), + }, + widgets.HotkeyLabel{ + frame={b=1, l=19}, + key='CUSTOM_SHIFT_D', + label='Delete command', + auto_width=true, + on_activate=self:callback('onDelCommand'), + }, + widgets.HotkeyLabel{ + frame={b=0, l=0}, + key='CUSTOM_SHIFT_E', + label='Edit command', + auto_width=true, + on_activate=self:callback('onEditCommand'), }, } @@ -92,7 +102,6 @@ end function QCMDDialog:submit(idx, choice) local screen = self.parent_view - local parent = screen._native.parent dfhack.screen.hideGuard(screen, function() dfhack.run_command(choice.command) end)