Sketcher: Prevent renaming interruption when hovering task elements. (#20458)
* Sketcher: Prevent renaming interruption when hovering task elements. Fixes #11842. * Sketcher: Refactored input focus check based on PR feedback (PR #20458) * Update src/Mod/Sketcher/Gui/TaskSketcherElements.cpp --------- Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#ifndef _PreComp_
|
||||
#include <QContextMenuEvent>
|
||||
#include <QImage>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
@@ -1694,8 +1695,17 @@ void TaskSketcherElements::onListWidgetElementsItemPressed(QListWidgetItem* it)
|
||||
ui->listWidgetElements->repaint();
|
||||
}
|
||||
|
||||
bool TaskSketcherElements::hasInputWidgetFocused()
|
||||
{
|
||||
QWidget* focusedWidget = QApplication::focusWidget();
|
||||
return qobject_cast<QLineEdit*>(focusedWidget) != nullptr;
|
||||
}
|
||||
|
||||
void TaskSketcherElements::onListWidgetElementsItemEntered(QListWidgetItem* item)
|
||||
{
|
||||
if (hasInputWidgetFocused()) {
|
||||
return;
|
||||
}
|
||||
ui->listWidgetElements->setFocus();
|
||||
|
||||
focusItemIndex = ui->listWidgetElements->row(item);
|
||||
@@ -1703,6 +1713,10 @@ void TaskSketcherElements::onListWidgetElementsItemEntered(QListWidgetItem* item
|
||||
|
||||
void TaskSketcherElements::onListWidgetElementsMouseMoveOnItem(QListWidgetItem* it)
|
||||
{
|
||||
if (hasInputWidgetFocused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ElementItem* item = static_cast<ElementItem*>(it);
|
||||
|
||||
if (!item
|
||||
|
||||
@@ -125,6 +125,8 @@ public:
|
||||
/// Observer message from the Selection
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
|
||||
|
||||
bool hasInputWidgetFocused();
|
||||
|
||||
private:
|
||||
void slotElementsChanged();
|
||||
void updateVisibility();
|
||||
|
||||
Reference in New Issue
Block a user