@@ -86,17 +86,47 @@ class FTappable extends StatefulWidget {
86
86
/// {@template forui.foundation.FTappable.onPress}
87
87
/// A callback for when the widget is pressed.
88
88
///
89
- /// The widget will be disabled if both [onPress] and [onLongPress] are null.
89
+ /// The widget will be disabled if the following are null:
90
+ /// * [onPress]
91
+ /// * [onLongPress]
92
+ /// * [onSecondaryPress]
93
+ /// * [onSecondaryLongPress]
90
94
/// {@endtemplate}
91
95
final VoidCallback ? onPress;
92
96
93
97
/// {@template forui.foundation.FTappable.onLongPress}
94
98
/// A callback for when the widget is long pressed.
95
99
///
96
- /// The widget will be disabled if both [onPress] and [onLongPress] are null.
100
+ /// The widget will be disabled if the following are null:
101
+ /// * [onPress]
102
+ /// * [onLongPress]
103
+ /// * [onSecondaryPress]
104
+ /// * [onSecondaryLongPress]
97
105
/// {@endtemplate}
98
106
final VoidCallback ? onLongPress;
99
107
108
+ /// {@template forui.foundation.FTappable.onSecondaryPress}
109
+ /// A callback for when the widget is pressed with a secondary button (usually right-click on desktop).
110
+ ///
111
+ /// The widget will be disabled if the following are null:
112
+ /// * [onPress]
113
+ /// * [onLongPress]
114
+ /// * [onSecondaryPress]
115
+ /// * [onSecondaryLongPress]
116
+ /// {@endtemplate}
117
+ final VoidCallback ? onSecondaryPress;
118
+
119
+ /// {@template forui.foundation.FTappable.onSecondaryLongPress}
120
+ /// A callback for when the widget is pressed with a secondary button (usually right-click on desktop).
121
+ ///
122
+ /// The widget will be disabled if the following are null:
123
+ /// * [onPress]
124
+ /// * [onLongPress]
125
+ /// * [onSecondaryPress]
126
+ /// * [onSecondaryLongPress]
127
+ /// {@endtemplate}
128
+ final VoidCallback ? onSecondaryLongPress;
129
+
100
130
/// {@template forui.foundation.FTappable.shortcuts}
101
131
/// The shortcuts. Defaults to calling [ActivateIntent] if [onPress] is not null.
102
132
/// {@endtemplate}
@@ -136,6 +166,8 @@ class FTappable extends StatefulWidget {
136
166
HitTestBehavior behavior,
137
167
VoidCallback ? onPress,
138
168
VoidCallback ? onLongPress,
169
+ VoidCallback ? onSecondaryPress,
170
+ VoidCallback ? onSecondaryLongPress,
139
171
Map <ShortcutActivator , Intent >? shortcuts,
140
172
Map <Type , Action <Intent >>? actions,
141
173
ValueWidgetBuilder <Set <WidgetState >> builder,
@@ -161,6 +193,8 @@ class FTappable extends StatefulWidget {
161
193
this .behavior = HitTestBehavior .translucent,
162
194
this .onPress,
163
195
this .onLongPress,
196
+ this .onSecondaryPress,
197
+ this .onSecondaryLongPress,
164
198
this .actions,
165
199
this .builder = _builder,
166
200
this .child,
@@ -191,12 +225,15 @@ class FTappable extends StatefulWidget {
191
225
..add (EnumProperty ('behavior' , behavior))
192
226
..add (ObjectFlagProperty .has ('onPress' , onPress))
193
227
..add (ObjectFlagProperty .has ('onLongPress' , onLongPress))
228
+ ..add (ObjectFlagProperty .has ('onSecondaryPress' , onSecondaryPress))
229
+ ..add (ObjectFlagProperty .has ('onSecondaryLongPress' , onSecondaryLongPress))
194
230
..add (DiagnosticsProperty ('shortcuts' , shortcuts))
195
231
..add (DiagnosticsProperty ('actions' , actions))
196
232
..add (ObjectFlagProperty .has ('builder' , builder));
197
233
}
198
234
199
- bool get _disabled => onPress == null && onLongPress == null ;
235
+ bool get _disabled =>
236
+ onPress == null && onLongPress == null && onSecondaryPress == null && onSecondaryLongPress == null ;
200
237
}
201
238
202
239
class _FTappableState <T extends FTappable > extends State <T > {
@@ -311,6 +348,8 @@ class _FTappableState<T extends FTappable> extends State<T> {
311
348
behavior: widget.behavior,
312
349
onTap: widget.onPress,
313
350
onLongPress: widget.onLongPress,
351
+ onSecondaryTap: widget.onSecondaryPress,
352
+ onSecondaryLongPress: widget.onSecondaryLongPress,
314
353
child: tappable,
315
354
),
316
355
),
@@ -354,6 +393,8 @@ class AnimatedTappable extends FTappable {
354
393
super .behavior,
355
394
super .onPress,
356
395
super .onLongPress,
396
+ super .onSecondaryPress,
397
+ super .onSecondaryLongPress,
357
398
super .shortcuts,
358
399
super .actions,
359
400
super .builder,
0 commit comments