Skip to content

Commit 796f283

Browse files
authoredDec 12, 2024
Merge pull request #7 from botwhytho/feature-enable-all-modifiers-button
Enable clicking a button while arbitrary modifiers are pressed [feenkcom/gtoolkit#4239]
2 parents 715ca12 + 0bbfb85 commit 796f283

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed
 

‎src/Brick/BrButton.class.st

+10
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ BrButton >> baselineOffset [
3636
ifNone: [ 0 ]
3737
]
3838

39+
{ #category : #'api - widget' }
40+
BrButton >> disableAllModifiers [
41+
self viewModel disableAllModifiers
42+
]
43+
44+
{ #category : #'api - widget' }
45+
BrButton >> enableAllModifiers [
46+
self viewModel enableAllModifiers
47+
]
48+
3949
{ #category : #accessing }
4050
BrButton >> gtActionFor: aView [
4151
<gtView>

‎src/Brick/BrButtonModel.class.st

+18-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Class {
1515
#name : #BrButtonModel,
1616
#superclass : #BrWidgetModel,
1717
#instVars : [
18-
'action'
18+
'action',
19+
'enableAllModifiers'
1920
],
2021
#category : #'Brick-Button - Model'
2122
}
@@ -56,6 +57,16 @@ BrButtonModel >> clickEvent: anEvent [
5657
ifFalse: [ self action gtValueWithArgs: { self widget . self . anEvent } ]
5758
]
5859

60+
{ #category : #'mouse handlers' }
61+
BrButtonModel >> disableAllModifiers [
62+
enableAllModifiers := false
63+
]
64+
65+
{ #category : #'mouse handlers' }
66+
BrButtonModel >> enableAllModifiers [
67+
enableAllModifiers := true
68+
]
69+
5970
{ #category : #'gt-extension' }
6071
BrButtonModel >> gtActionFor: aView [
6172
<gtView>
@@ -90,14 +101,18 @@ BrButtonModel >> hasModifiers: anEvent [
90101
BrButtonModel >> initialize [
91102
super initialize.
92103

93-
action := [ :anElement :aButtonModel :anEvent | ]
104+
action := [ :anElement :aButtonModel :anEvent | ].
105+
self disableAllModifiers
94106
]
95107

96108
{ #category : #initialization }
97109
BrButtonModel >> initializeListeners [
98110
self
99111
when: BlClickEvent
100-
do: [ :anEvent | (self hasModifiers: anEvent) ifFalse: [ self clickEvent: anEvent ] ].
112+
do: [ :anEvent |
113+
(enableAllModifiers or: [ (self hasModifiers: anEvent) not ])
114+
ifTrue: [ self clickEvent: anEvent ] ].
115+
101116
self
102117
when: BlFocusInEvent
103118
do: [ self

0 commit comments

Comments
 (0)