Skip to content

Commit

Permalink
Recenter view and set focus when initialized (BehaviorTree#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
Affonso-Gui committed Nov 12, 2022
1 parent c9a5606 commit 55eabcc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bt_editor/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,14 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
}
}

void MainWindow::showEvent(QShowEvent *event)
{
if (!event->spontaneous()) {
currentTabInfo()->zoomHomeView();
ui->centralwidget->setFocus();
}
}

void MainWindow::resizeEvent(QResizeEvent *)
{
on_splitter_splitterMoved();
Expand Down
3 changes: 3 additions & 0 deletions bt_editor/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <nodes/Node>
#include <QTreeWidgetItem>
#include <QShortcut>
#include <QShowEvent>
#include <QTimer>
#include <deque>
#include <thread>
Expand Down Expand Up @@ -142,6 +143,8 @@ private slots:

bool eventFilter(QObject *obj, QEvent *event) override;

void showEvent(QShowEvent *event) override;

void resizeEvent(QResizeEvent *) override;

GraphicContainer* createTab(const QString &name);
Expand Down

0 comments on commit 55eabcc

Please sign in to comment.