Skip to content

Sync Box mouse wheel scroll with Panel/ScrollBar impl; fix InputBox cursor stuck as IDC_IBEAM on Panel mouse-leave#64

Merged
FeJS8888 merged 8 commits intomainfrom
copilot/update-box-scroll-implementation
Mar 17, 2026
Merged

Sync Box mouse wheel scroll with Panel/ScrollBar impl; fix InputBox cursor stuck as IDC_IBEAM on Panel mouse-leave#64
FeJS8888 merged 8 commits intomainfrom
copilot/update-box-scroll-implementation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits March 7, 2026 09:24
Co-authored-by: FeJS8888 <110683147+FeJS8888@users.noreply.github.com>
Co-authored-by: FeJS8888 <110683147+FeJS8888@users.noreply.github.com>
Co-authored-by: FeJS8888 <110683147+FeJS8888@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Box mouse scroll implementation and fix InputBox pointer bug Sync Box mouse wheel scroll with Panel/ScrollBar impl; fix InputBox cursor stuck as IDC_IBEAM on Panel mouse-leave Mar 7, 2026
@FeJS8888
Copy link
Copy Markdown
Owner

FeJS8888 commented Mar 7, 2026

@copilot 现在有如下问题,Panel等在处理鼠标滚动的时候,如果内部输入框有焦点,无法滚动。

… focusingWidget==this

Co-authored-by: FeJS8888 <110683147+FeJS8888@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 7, 2026

@copilot 现在有如下问题,Panel等在处理鼠标滚动的时候,如果内部输入框有焦点,无法滚动。

Fixed in 8e4c368.

Root cause: the scrollbar wheel-event guard was focusingWidget == this, which blocked scrolling whenever a child widget (e.g. InputBox) had focus. Changed to isin (mouse is inside the Panel) — wheel events now always reach the scrollbar as long as the pointer is within the Panel, regardless of which widget has focus.

@FeJS8888
Copy link
Copy Markdown
Owner

FeJS8888 commented Mar 8, 2026

@copilot 现在我们在鼠标停留在Panel的某个超出范围的不可见的InputBox上方,鼠标指针会被不正确的设置。请仔细阅读逻辑,进行修复

…mouse-leave

Co-authored-by: FeJS8888 <110683147+FeJS8888@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 8, 2026

@copilot 现在我们在鼠标停留在Panel的某个超出范围的不可见的InputBox上方,鼠标指针会被不正确的设置。请仔细阅读逻辑,进行修复

Fixed in 57c6db9.

Root cause: the mouse-leave dispatch was forwarding the real mouse coordinates to all children. When a child InputBox is scrolled out of the Panel viewport, its absolute position is placed outside the Panel bounds (that's how scroll works). If the real mouse happened to be at that same out-of-panel location, InputBox::isInside returned true and incorrectly set IDC_IBEAM.

Fix: replace the real coordinates with a synthetic leaveMsg at (-99999, -99999) — guaranteed outside every widget — so children only enter the lastInside → false reset path, never the isInside = true cursor-set path.

@FeJS8888 FeJS8888 marked this pull request as ready for review March 17, 2026 09:30
Copilot AI review requested due to automatic review settings March 17, 2026 09:30
@FeJS8888 FeJS8888 merged commit d794916 into main Mar 17, 2026
4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns Box mouse-wheel scrolling behavior with the existing Panel/ScrollBar smooth-scroll implementation, and fixes several PanelInputBox interaction bugs (cursor shape and scroll dispatch when a child has focus).

Changes:

  • Implement smooth mouse-wheel scrolling for Box (without a visible scrollbar), mirroring Panel/ScrollBar behavior.
  • Fix cursor getting stuck as IDC_IBEAM by dispatching a synthetic mouse-leave to children when leaving a Panel.
  • Add a Widget::reset() hook and propagate reset/redraw across containers; update .gitignore and bump xege submodule.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.

File Description
src/Widget.cpp Implements reset hooks; adjusts Panel scrollbar + leave dispatch; adds Box smooth wheel scrolling; tweaks InputBox content sync; resets on order assignment.
include/Widget.h Introduces Widget::reset() and shared needRedraw; adds overrides for Panel/Button/InputBox/Box; extends InputBox setContent API.
3rdparty/xege Updates submodule commit.
.gitignore Ignores common CMake/build output directories/files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Widget.cpp
Comment on lines +406 to +413
if (msg.is_move() && (mouseOwningFlag == nullptr || mouseOwningFlag == this)) {
mouse_msg leaveMsg = msg;
leaveMsg.x = -99999;
leaveMsg.y = -99999;
for (Widget* w : children) {
w->handleEvent(leaveMsg);
}
}
Comment thread src/Widget.cpp

void assignOrder(std::vector<Widget*> widgetWithOrder){
swap(widgetWithOrder,widgets);
for(Widget* w : widgetWithOrder){
Comment thread src/Widget.cpp
Comment on lines +922 to +924
ripples.shrink_to_fit();
}

Comment thread src/Widget.cpp
Comment on lines +1531 to +1533
ripples.shrink_to_fit();
}

Comment thread src/Widget.cpp
Comment on lines +3997 to +4001
if (layout) {
LayoutResult extentResult = layout->apply(*this, 0);
double contentH = extentResult.contentMaxY - extentResult.contentMinY;
double viewH = height / (scale > 0 ? scale : 1.0);
double maxScroll = contentH - viewH;
Comment thread src/Widget.cpp
Comment on lines +4034 to +4035
// 应用布局(带滚动偏移)
if (layout) layout->apply(*this, layoutScrollOffset);
@FeJS8888 FeJS8888 deleted the copilot/update-box-scroll-implementation branch March 24, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants