]> git.lyx.org Git - features.git/commitdiff
Prepare for advanced mouse click selections.
authorAbdelrazak Younes <younes@lyx.org>
Sat, 27 Jan 2007 10:41:03 +0000 (10:41 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 27 Jan 2007 10:41:03 +0000 (10:41 +0000)
* WorkArea::dispatch(): add modifiers argument.

* GuiWorkArea::mousePressEvent(): transmit the modifier to WorkArea::dispatch().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16878 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/WorkArea.C
src/frontends/WorkArea.h
src/frontends/qt4/GuiWorkArea.C

index 643447e6b47049bd367658c38edbe1bdd13a1bec..abe266cd79d7aad543f961d57f856cb6a37dfd2f 100644 (file)
@@ -182,7 +182,7 @@ void WorkArea::processKeySym(LyXKeySymPtr key, key_modifier::state state)
 }
 
 
-void WorkArea::dispatch(FuncRequest const & cmd0)
+void WorkArea::dispatch(FuncRequest const & cmd0, key_modifier::state k)
 {
        // Handle drag&drop
        if (cmd0.action == LFUN_FILE_OPEN) {
@@ -192,10 +192,23 @@ void WorkArea::dispatch(FuncRequest const & cmd0)
 
        theLyXFunc().setLyXView(&lyx_view_);
 
-       bool needRedraw = buffer_view_->workAreaDispatch(cmd0);
+       FuncRequest cmd;
+
+       if (cmd0.action == LFUN_MOUSE_PRESS) {
+               if (k == key_modifier::shift)
+                       cmd = FuncRequest(cmd0, "region-select");
+               else if (k == key_modifier::ctrl)
+                       cmd = FuncRequest(cmd0, "paragraph-select");
+               else
+                       cmd = cmd0;
+       }
+       else
+               cmd = cmd0;
+
+       bool needRedraw = buffer_view_->workAreaDispatch(cmd);
 
        // Skip these when selecting
-       if (cmd0.action != LFUN_MOUSE_MOTION) {
+       if (cmd.action != LFUN_MOUSE_MOTION) {
                lyx_view_.updateLayoutChoice();
                lyx_view_.updateMenubar();
                lyx_view_.updateToolbars();
@@ -203,14 +216,14 @@ void WorkArea::dispatch(FuncRequest const & cmd0)
 
        
        // GUI tweaks except with mouse motion with no button pressed.
-       if (!(cmd0.action == LFUN_MOUSE_MOTION 
-               && cmd0.button() == mouse_button::none)) {
+       if (!(cmd.action == LFUN_MOUSE_MOTION 
+               && cmd.button() == mouse_button::none)) {
                // Slight hack: this is only called currently when we
                // clicked somewhere, so we force through the display
                // of the new status here.
                lyx_view_.clearMessage();
 
-               // Show the cursor immediately after any operation.
+               // Show the cursor       immediately after any operation.
                hideCursor();
                toggleCursor();
        }
index bca23d19f98943ae86b3c53c6efc732bdb23c399..12baf4321722eeee7fedf2ec3081abe2f9e37314 100644 (file)
@@ -98,7 +98,8 @@ protected:
        /// cause the display of the given area of the work area
        virtual void expose(int x, int y, int w, int h) = 0;
        ///
-       void dispatch(FuncRequest const & cmd0);
+       void dispatch(FuncRequest const & cmd0,
+               key_modifier::state = key_modifier::none);
        ///
        void resizeBufferView();
        ///
index 10ccfe8b7853fe63216d14417543c8e4ad31b7dc..261aaef8f8b9e224cdf84a1d65616916fb31f665 100644 (file)
@@ -290,8 +290,8 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
        }
 
        FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
-                             q_button_state(e->button()));
-       dispatch(cmd);
+               q_button_state(e->button()));
+       dispatch(cmd, q_key_state(e->modifiers()));
 }