feat: Middle Click (#51)
* paste on middle click * middle click to close tab * middle click to reply
This commit is contained in:
@@ -1136,8 +1136,14 @@ impl InputState {
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if event.button == MouseButton::Middle {
|
||||
self.paste(&Paste, window, cx);
|
||||
return;
|
||||
}
|
||||
|
||||
self.selecting = true;
|
||||
let offset = self.index_for_mouse_position(event.position, window, cx);
|
||||
|
||||
// Double click to select word
|
||||
if event.button == MouseButton::Left && event.click_count == 2 {
|
||||
self.select_word(offset, window, cx);
|
||||
@@ -1213,9 +1219,10 @@ impl InputState {
|
||||
self.replace_text_in_range(None, "", window, cx);
|
||||
}
|
||||
|
||||
pub(super) fn paste(&mut self, _: &Paste, window: &mut Window, cx: &mut Context<Self>) {
|
||||
pub(super) fn paste(&mut self, _paste: &Paste, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if let Some(clipboard) = cx.read_from_clipboard() {
|
||||
let mut new_text = clipboard.text().unwrap_or_default();
|
||||
|
||||
if !self.is_multi_line() {
|
||||
new_text = new_text.replace('\n', "");
|
||||
}
|
||||
|
||||
@@ -218,6 +218,10 @@ impl RenderOnce for TextInput {
|
||||
MouseButton::Left,
|
||||
window.listener_for(&self.state, InputState::on_mouse_down),
|
||||
)
|
||||
.on_mouse_down(
|
||||
MouseButton::Middle,
|
||||
window.listener_for(&self.state, InputState::on_mouse_down),
|
||||
)
|
||||
.on_mouse_up(
|
||||
MouseButton::Left,
|
||||
window.listener_for(&self.state, InputState::on_mouse_up),
|
||||
|
||||
Reference in New Issue
Block a user