@@ -1200,20 +1200,35 @@ pub struct EventFilter {
12001200 /// If `true`, pressing horizontal arrows will act on the
12011201 /// widget, and NOT move focus away from the focused widget.
12021202 ///
1203- /// Default: `false`
1203+ /// Defaults to `false`, but is always `true` in [`TextEdit`].
12041204 pub horizontal_arrows : bool ,
12051205
12061206 /// If `true`, pressing vertical arrows will act on the
12071207 /// widget, and NOT move focus away from the focused widget.
12081208 ///
1209- /// Default: `false`
1209+ /// Defaults to `false`, but is always `true` in [`TextEdit`].
12101210 pub vertical_arrows : bool ,
12111211
12121212 /// If `true`, pressing escape will act on the widget,
12131213 /// and NOT surrender focus from the focused widget.
12141214 ///
12151215 /// Default: `false`
12161216 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 ,
12171232}
12181233
12191234#[ allow( clippy:: derivable_impls) ] // let's be explicit
@@ -1224,22 +1239,27 @@ impl Default for EventFilter {
12241239 horizontal_arrows : false ,
12251240 vertical_arrows : false ,
12261241 escape : false ,
1242+ copy : true ,
1243+ cut : true ,
1244+ paste : true ,
12271245 }
12281246 }
12291247}
12301248
12311249impl EventFilter {
12321250 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 {
12351253 crate :: Key :: Tab => self . tab ,
12361254 crate :: Key :: ArrowUp | crate :: Key :: ArrowDown => self . vertical_arrows ,
12371255 crate :: Key :: ArrowRight | crate :: Key :: ArrowLeft => self . horizontal_arrows ,
12381256 crate :: Key :: Escape => self . escape ,
12391257 _ => true ,
1240- }
1241- } else {
1242- true
1258+ } ,
1259+ Event :: Copy => self . copy ,
1260+ Event :: Cut => self . cut ,
1261+ Event :: Paste ( _) => self . paste ,
1262+ _ => true ,
12431263 }
12441264 }
12451265}
0 commit comments