Skip to content

Commit b378689

Browse files
committed
Allow "Space" key to trigger OK button on dialogs
...same as the "Enter" key. Relates to #566. Thank you to @dbojan for the suggestion!
1 parent 3914151 commit b378689

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

Classes/pdObjectList.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ End Function
630630
Private Function HandleMsg_WM_KEYDOWN(ByVal hWnd As Long, ByVal uiMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal dwRefData As Long, ByRef eatMsg As Boolean) As Long
631631

632632
'The only keypresses we currently care about are ENTER and ESCAPE
633-
If (wParam = pdnk_Enter) Or (wParam = pdnk_Escape) Then
633+
If (wParam = pdnk_Enter) Or (wParam = pdnk_Escape) Or (wParam = pdnk_Space) Then
634634

635635
'See if this form 1) is a raised dialog, and 2) contains a command bar
636636
If Interface.IsModalDialogActive() Then

Classes/pdUCSupport.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ Private Sub m_KeyEvents_KeyDownCustom(ByVal Shift As ShiftConstants, ByVal vkCod
837837

838838
'Handle navigation keys separately (unless the keypress was already eaten by the attached control)
839839
If (Not markEventHandled) And m_ControlCanGetFocus Then
840-
If (vkCode = pdnk_Enter) Or (vkCode = pdnk_Escape) Or (vkCode = pdnk_Tab) Then RaiseEvent KeyDownSystem(Shift, vkCode, markEventHandled)
840+
If (vkCode = pdnk_Enter) Or (vkCode = pdnk_Escape) Or (vkCode = pdnk_Space) Or (vkCode = pdnk_Tab) Then RaiseEvent KeyDownSystem(Shift, vkCode, markEventHandled)
841841
End If
842842

843843
End Sub

Controls/pdCommandBar.ctl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ Private Sub ucSupport_CustomMessage(ByVal wMsg As Long, ByVal wParam As Long, By
919919

920920
'This is a relevant navigation key!
921921

922-
'Interpret Enter as OK...
923-
If (wParam = pdnk_Enter) Then
922+
'Interpret Enter or Space as OK...
923+
If (wParam = pdnk_Enter) Or (wParam = pdnk_Space) Then
924924
HandleOKButton
925925
bHandled = True
926926

@@ -941,8 +941,8 @@ End Sub
941941
'If the command bar itself has focus, manually handle Enter/Esc as OK/Cancel events
942942
Private Sub ucSupport_KeyDownSystem(ByVal Shift As ShiftConstants, ByVal whichSysKey As PD_NavigationKey, markEventHandled As Boolean)
943943

944-
'Interpret Enter as OK...
945-
If (whichSysKey = pdnk_Enter) Then
944+
'Interpret Enter or Space as OK...
945+
If (whichSysKey = pdnk_Enter) Or (whichSysKey = pdnk_Space) Then
946946
markEventHandled = True
947947
HandleOKButton
948948

Controls/pdCommandBarMini.ctl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ Private Sub ucSupport_CustomMessage(ByVal wMsg As Long, ByVal wParam As Long, By
256256

257257
'This is a relevant navigation key!
258258

259-
'Interpret Enter as OK...
260-
If (wParam = pdnk_Enter) Then
259+
'Interpret Enter or Space as OK...
260+
If (wParam = pdnk_Enter) Or (wParam = pdnk_Space) Then
261261
HandleOKButton
262262
bHandled = True
263263

@@ -278,8 +278,8 @@ End Sub
278278
'If the command bar itself has focus, manually handle Enter/Esc as OK/Cancel events
279279
Private Sub ucSupport_KeyDownSystem(ByVal Shift As ShiftConstants, ByVal whichSysKey As PD_NavigationKey, markEventHandled As Boolean)
280280

281-
'Interpret Enter as OK...
282-
If (whichSysKey = pdnk_Enter) Then
281+
'Interpret Enter or Space as OK...
282+
If (whichSysKey = pdnk_Enter) Or (whichSysKey = pdnk_Space) Then
283283
markEventHandled = True
284284
HandleOKButton
285285

Modules/NavKey.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ Public Function NotifyNavKeypress(ByRef childObject As Object, ByVal navKeyCode
194194

195195
'For Enter and Esc keypresses, we want to see if the target form contains a command bar. If it does,
196196
' we'll directly invoke the appropriate keypress.
197-
If (navKeyCode = pdnk_Enter) Or (navKeyCode = pdnk_Escape) Then
197+
If (navKeyCode = pdnk_Enter) Or (navKeyCode = pdnk_Escape) Or (navKeyCode = pdnk_Space) Then
198198

199199
'See if this form 1) is a raised dialog, and 2) contains a command bar
200200
If Interface.IsModalDialogActive() Then

Modules/PublicEnumsAndTypes.bas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,11 +714,12 @@ End Type
714714
Public Enum PD_NavigationKey
715715
pdnk_Enter = vbKeyReturn
716716
pdnk_Escape = vbKeyEscape
717+
pdnk_Space = vbKeySpace
717718
pdnk_Tab = vbKeyTab
718719
End Enum
719720

720721
#If False Then
721-
Private Const pdnk_Enter = vbKeyReturn, pdnk_Escape = vbKeyEscape, pdnk_Tab = vbKeyTab
722+
Private Const pdnk_Enter = vbKeyReturn, pdnk_Escape = vbKeyEscape, pdnk_Space = vbKeySpace, pdnk_Tab = vbKeyTab
722723
#End If
723724

724725
'Prior to 7.0, only selections offered detailed control over smoothing. However, new tools (like flood fills)

PhotoDemon.vbp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ Description="PhotoDemon Photo Editor"
527527
CompatibleMode="0"
528528
MajorVer=2024
529529
MinorVer=8
530-
RevisionVer=6
530+
RevisionVer=7
531531
AutoIncrementVer=1
532532
ServerSupportFiles=0
533533
VersionComments="Copyright 2000-2024 Tanner Helland - photodemon.org"

0 commit comments

Comments
 (0)