Issue-1058: implemented backspace button for path and polygon (#1061)

This commit is contained in:
Matthias Köfferlein 2022-04-10 18:41:58 +02:00 committed by GitHub
parent 0df479b29c
commit cb527cc50b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 2 deletions

View File

@ -796,6 +796,17 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio
}
}
bool
Service::key_event (unsigned int key, unsigned int buttons)
{
if (view ()->is_editable () && m_editing && buttons == 0 && key == Qt::Key_Backspace) {
do_delete ();
return true;
} else {
return false;
}
}
void
Service::activated ()
{

View File

@ -322,6 +322,11 @@ public:
*/
virtual bool mouse_double_click_event (const db::DPoint &p, unsigned int buttons, bool prio);
/**
* @brief Implements the key handler
*/
virtual bool key_event (unsigned int /*key*/, unsigned int /*buttons*/);
/**
* @brief Implement the mouse mode: deactivate mouse mode
*/
@ -430,6 +435,13 @@ protected:
*/
virtual bool do_mouse_click (const db::DPoint & /*p*/) { return false; }
/**
* @brief Reimplemented by the specific implementation of the shape editors
*
* This method is called when the backspace button is pressed
*/
virtual void do_delete () { }
/**
* @brief Reimplemented by the specific implementation of the shape editors
*

View File

@ -420,6 +420,16 @@ PolygonService::do_mouse_move_inactive (const db::DPoint &p)
mouse_cursor_from_snap_details (snap_details);
}
void
PolygonService::do_delete ()
{
if (m_points.size () > 2) {
m_points.erase (m_points.end () - 2);
m_last = m_points.end()[-2];
update_marker ();
}
}
void
PolygonService::do_mouse_move (const db::DPoint &p)
{
@ -1058,7 +1068,17 @@ PathService::do_mouse_click (const db::DPoint &p)
return false;
}
void
void
PathService::do_delete ()
{
if (m_points.size () > 2) {
m_points.erase (m_points.end () - 2);
m_last = m_points.end()[-2];
update_marker ();
}
}
void
PathService::do_finish_edit ()
{
// one point is reserved for the "current one"

View File

@ -89,6 +89,7 @@ public:
PolygonService (db::Manager *manager, lay::LayoutView *view);
virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_delete ();
virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p);
virtual void do_mouse_move_inactive (const db::DPoint &p);
@ -181,6 +182,7 @@ public:
virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p);
virtual void do_mouse_move_inactive (const db::DPoint &p);
virtual void do_delete ();
virtual void do_finish_edit ();
virtual void do_cancel_edit ();
virtual bool do_activated ();

View File

@ -130,7 +130,6 @@ private:
std::vector<lay::ViewObject *> m_mouse_cursor_markers;
QColor m_cursor_color;
bool m_cursor_enabled;
lay::LayoutView *mp_view;
bool m_has_tracking_position;
db::DPoint m_tracking_position;
};