imgui: Attempt to fix Tab key
This commit is contained in:
parent
73daf085e6
commit
bf699462c3
5 changed files with 15 additions and 12 deletions
|
@ -4085,6 +4085,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
|
|||
wxDEFINE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
|
||||
|
||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
||||
: m_canvas(canvas)
|
||||
|
@ -5322,10 +5323,15 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||
if (evt.GetEventType() == wxEVT_KEY_UP) {
|
||||
const int keyCode = evt.GetKeyCode();
|
||||
|
||||
if (keyCode == WXK_TAB) {
|
||||
// Enable switching between 3D and Preview with Tab
|
||||
// m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_TAB));
|
||||
} else if (m_gizmos.get_current_type() == Gizmos::SlaSupports && keyCode == WXK_SHIFT && m_gizmos.mouse_event(SLAGizmoEventType::ShiftUp)) {
|
||||
// shift has been just released - SLA gizmo might want to close rectangular selection.
|
||||
if (m_gizmos.get_current_type() == Gizmos::SlaSupports && keyCode == WXK_SHIFT && m_gizmos.mouse_event(SLAGizmoEventType::ShiftUp))
|
||||
m_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
evt.Skip(); // Needed to have EVT_CHAR generated as well
|
||||
}
|
||||
|
|
|
@ -131,6 +131,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent);
|
|||
wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
|
||||
|
||||
// this describes events being passed from GLCanvas3D to SlaSupport gizmo
|
||||
enum class SLAGizmoEventType {
|
||||
|
|
|
@ -229,7 +229,7 @@ bool Preview::init(wxWindow* parent, DynamicPrintConfig* config, BackgroundSlici
|
|||
if ((config == nullptr) || (process == nullptr) || (gcode_preview_data == nullptr))
|
||||
return false;
|
||||
|
||||
if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize))
|
||||
if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */))
|
||||
return false;
|
||||
|
||||
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
||||
|
|
|
@ -138,11 +138,8 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
|
|||
io.KeyAlt = evt.AltDown();
|
||||
io.KeySuper = evt.MetaDown();
|
||||
|
||||
// XXX: Unfortunatelly this seems broken due to some interference with wxWidgets,
|
||||
// we have to return true always (perform re-render).
|
||||
// new_frame();
|
||||
// return want_keyboard() || want_text_input();
|
||||
return true;
|
||||
new_frame();
|
||||
return want_keyboard() || want_text_input();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1146,9 +1146,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
|
||||
view3D = new View3D(q, &model, config, &background_process);
|
||||
preview = new Preview(q, config, &background_process, &gcode_preview_data, [this](){ schedule_background_process(); });
|
||||
// Let the Tab key switch between the 3D view and the layer preview.
|
||||
view3D->Bind(wxEVT_NAVIGATION_KEY, [this](wxNavigationKeyEvent &evt) { if (evt.IsFromTab()) this->select_next_view_3D(); });
|
||||
preview->Bind(wxEVT_NAVIGATION_KEY, [this](wxNavigationKeyEvent &evt) { if (evt.IsFromTab()) this->select_next_view_3D(); });
|
||||
|
||||
panels.push_back(view3D);
|
||||
panels.push_back(preview);
|
||||
|
@ -1201,6 +1198,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
view3D_canvas->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, [this](Event<bool> &evt) { this->sidebar->enable_buttons(evt.data); });
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this);
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this);
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); });
|
||||
// 3DScene/Toolbar:
|
||||
view3D_canvas->Bind(EVT_GLTOOLBAR_ADD, &priv::on_action_add, this);
|
||||
view3D_canvas->Bind(EVT_GLTOOLBAR_DELETE, [q](SimpleEvent&) { q->remove_selected(); });
|
||||
|
@ -1216,6 +1214,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
// Preview events:
|
||||
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
|
||||
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_QUESTION_MARK, [this](SimpleEvent&) { wxGetApp().keyboard_shortcuts(); });
|
||||
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); });
|
||||
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_INIT, [this](SimpleEvent&) { init_view_toolbar(); });
|
||||
|
||||
|
|
Loading…
Reference in a new issue