@@ -1200,20 +1200,35 @@ pub struct EventFilter {
1200
1200
/// If `true`, pressing horizontal arrows will act on the
1201
1201
/// widget, and NOT move focus away from the focused widget.
1202
1202
///
1203
- /// Default: `false`
1203
+ /// Defaults to `false`, but is always `true` in [`TextEdit`].
1204
1204
pub horizontal_arrows : bool ,
1205
1205
1206
1206
/// If `true`, pressing vertical arrows will act on the
1207
1207
/// widget, and NOT move focus away from the focused widget.
1208
1208
///
1209
- /// Default: `false`
1209
+ /// Defaults to `false`, but is always `true` in [`TextEdit`].
1210
1210
pub vertical_arrows : bool ,
1211
1211
1212
1212
/// If `true`, pressing escape will act on the widget,
1213
1213
/// and NOT surrender focus from the focused widget.
1214
1214
///
1215
1215
/// Default: `false`
1216
1216
pub escape : bool ,
1217
+
1218
+ /// If `true`, a copy action (like Ctrl+C) will be handled by the widget.
1219
+ ///
1220
+ /// Default: `true`
1221
+ pub copy : bool ,
1222
+
1223
+ /// If `true`, a cut action (like Ctrl+X) will be handled by the widget.
1224
+ ///
1225
+ /// Default: `true`
1226
+ pub cut : bool ,
1227
+
1228
+ /// If `true`, a paste action (like Ctrl+V) will be handled by the widget.
1229
+ ///
1230
+ /// Default: `true`
1231
+ pub paste : bool ,
1217
1232
}
1218
1233
1219
1234
#[ allow( clippy:: derivable_impls) ] // let's be explicit
@@ -1224,22 +1239,27 @@ impl Default for EventFilter {
1224
1239
horizontal_arrows : false ,
1225
1240
vertical_arrows : false ,
1226
1241
escape : false ,
1242
+ copy : true ,
1243
+ cut : true ,
1244
+ paste : true ,
1227
1245
}
1228
1246
}
1229
1247
}
1230
1248
1231
1249
impl EventFilter {
1232
1250
pub fn matches ( & self , event : & Event ) -> bool {
1233
- if let Event :: Key { key , .. } = event {
1234
- match key {
1251
+ match event {
1252
+ Event :: Key { key , .. } => match key {
1235
1253
crate :: Key :: Tab => self . tab ,
1236
1254
crate :: Key :: ArrowUp | crate :: Key :: ArrowDown => self . vertical_arrows ,
1237
1255
crate :: Key :: ArrowRight | crate :: Key :: ArrowLeft => self . horizontal_arrows ,
1238
1256
crate :: Key :: Escape => self . escape ,
1239
1257
_ => true ,
1240
- }
1241
- } else {
1242
- true
1258
+ } ,
1259
+ Event :: Copy => self . copy ,
1260
+ Event :: Cut => self . cut ,
1261
+ Event :: Paste ( _) => self . paste ,
1262
+ _ => true ,
1243
1263
}
1244
1264
}
1245
1265
}
0 commit comments