fix(mtext): keep arrows in editor
Route captured arrows to the MText caret only while the hidden command input retains focus.\n\nRefs #655
This commit is contained in:
commit
76ad642d0c
3 changed files with 22 additions and 4 deletions
|
|
@ -1972,9 +1972,9 @@ pub enum Message {
|
|||
},
|
||||
/// A widget captured Up/Down; resolve it only if the command input owns
|
||||
/// keyboard focus.
|
||||
CommandLineArrowProbe { direction: ArrowKey },
|
||||
CommandLineArrowProbe { direction: ArrowKey, extend_selection: bool },
|
||||
/// Result of the command-input focus query for a captured Up/Down key.
|
||||
CommandLineArrowResolved { direction: ArrowKey, focused: bool },
|
||||
CommandLineArrowResolved { direction: ArrowKey, focused: bool, extend_selection: bool },
|
||||
/// Toggle the dropdown listing the full command-line history.
|
||||
CommandHistoryToggle,
|
||||
/// Grab/move/release the expanded history panel's top resize edge.
|
||||
|
|
|
|||
|
|
@ -1559,20 +1559,37 @@ impl OpenCADStudio {
|
|||
))
|
||||
}
|
||||
|
||||
Message::CommandLineArrowProbe { direction } => {
|
||||
Message::CommandLineArrowProbe {
|
||||
direction,
|
||||
extend_selection,
|
||||
} => {
|
||||
iced::widget::operation::is_focused(iced::widget::Id::new(
|
||||
crate::ui::command_line::CMD_INPUT_ID,
|
||||
))
|
||||
.map(move |focused| Message::CommandLineArrowResolved {
|
||||
direction,
|
||||
focused,
|
||||
extend_selection,
|
||||
})
|
||||
}
|
||||
|
||||
Message::CommandLineArrowResolved { direction, focused } => {
|
||||
Message::CommandLineArrowResolved {
|
||||
direction,
|
||||
focused,
|
||||
extend_selection,
|
||||
} => {
|
||||
if !focused {
|
||||
return Task::none();
|
||||
}
|
||||
// The editor inherits arrows captured by the focused command line.
|
||||
if self.mtext_editor.is_some() {
|
||||
match direction {
|
||||
ArrowKey::Up => self.mtext_caret_move_vertical(1, extend_selection),
|
||||
ArrowKey::Down => self.mtext_caret_move_vertical(-1, extend_selection),
|
||||
ArrowKey::Left | ArrowKey::Right => {}
|
||||
}
|
||||
return Task::none();
|
||||
}
|
||||
match direction {
|
||||
ArrowKey::Up => self.update(Message::CommandHistoryPrev),
|
||||
ArrowKey::Down => self.update(Message::CommandHistoryNext),
|
||||
|
|
|
|||
|
|
@ -2266,6 +2266,7 @@ impl OpenCADStudio {
|
|||
{
|
||||
return Some(Message::CommandLineArrowProbe {
|
||||
direction: arrow?,
|
||||
extend_selection: modifiers.shift(),
|
||||
});
|
||||
}
|
||||
// A focused web text field needs the browser clipboard;
|
||||
|
|
|
|||
Loading…
Reference in a new issue