Skip to content

Commit

Permalink
Merge pull request #4934 from shun-iwasawa/fix_text_edit
Browse files Browse the repository at this point in the history
Fix Text Iwa Fx input field (again)
  • Loading branch information
RodneyBaker authored Jun 6, 2023
2 parents 1772fe6 + dfd2f7a commit 42fd9b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
1 change: 0 additions & 1 deletion toonz/sources/include/toonzqt/paramfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ class MyTextEdit : public QTextEdit {
protected:
void keyPressEvent(QKeyEvent *event) override;
void focusOutEvent(QFocusEvent *e) override;
bool eventFilter(QObject *, QEvent *) override;

signals:
void edited();
Expand Down
4 changes: 3 additions & 1 deletion toonz/sources/toonz/pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <QDesktopWidget>
#include <QDialog>
#include <QLineEdit>
#include <QTextEdit>
#include <QScreen>

extern TEnv::StringVar EnvSafeAreaName;
Expand Down Expand Up @@ -123,7 +124,8 @@ void TPanel::enterEvent(QEvent *event) {
if (w) {
// grab the focus, unless a line-edit is focused currently
QWidget *focusWidget = qApp->focusWidget();
if (focusWidget && dynamic_cast<QLineEdit *>(focusWidget)) {
if (focusWidget && (dynamic_cast<QLineEdit *>(focusWidget) ||
dynamic_cast<QTextEdit *>(focusWidget))) {
event->accept();
return;
}
Expand Down
23 changes: 1 addition & 22 deletions toonz/sources/toonzqt/paramfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,9 +1565,7 @@ void IntParamField::update(int frame) {
namespace component {

MyTextEdit::MyTextEdit(const QString &text, QWidget *parent)
: QTextEdit(text, parent) {
installEventFilter(this);
}
: QTextEdit(text, parent) {}

void MyTextEdit::keyPressEvent(QKeyEvent *event) {
QTextEdit::keyPressEvent(event);
Expand All @@ -1579,25 +1577,6 @@ void MyTextEdit::focusOutEvent(QFocusEvent *event) {
emit edited();
}

bool MyTextEdit::eventFilter(QObject *obj, QEvent *e) {
if (e->type() != QEvent::ShortcutOverride)
return QTextEdit::eventFilter(obj, e);

QKeyEvent *ke = (QKeyEvent *)e;
std::string keyStr =
QKeySequence(ke->key() + ke->modifiers()).toString().toStdString();
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
if (!action) return QTextEdit::eventFilter(obj, e);

std::string actionId = CommandManager::instance()->getIdFromAction(action);
if (actionId == "MI_Undo" || actionId == "MI_Redo" ||
actionId == "MI_Clear" || actionId == "MI_Copy" ||
actionId == "MI_Paste" || actionId == "MI_Cut")
return QTextEdit::eventFilter(obj, e);

return true;
}

}; // namespace component

StringParamField::StringParamField(QWidget *parent, QString name,
Expand Down

0 comments on commit 42fd9b7

Please sign in to comment.