From 7a1ed1d59f405e708589ba70fe1197b711d0066c Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Sun, 26 Apr 2026 05:00:52 +0300 Subject: [PATCH] Fix tap-status-bar-to-scroll when global Toolbar is in use (#3589) Toolbar.initTitleBarStatus created a plain Container as the StatusBar, ignoring statusBarScrollsUpBool. With the global Toolbar (the modern default), the iOS fake tap forwarded by cn1StatusBarTapProxy at (width/2, 0) landed on a non-clickable Container, so scroll-to-top never fired. Mirror Form.createStatusBar by creating a Button with the scroll-to-top listener when statusBarScrollsUpBool is true. Co-Authored-By: Claude Opus 4.7 (1M context) --- CodenameOne/src/com/codename1/ui/Toolbar.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/CodenameOne/src/com/codename1/ui/Toolbar.java b/CodenameOne/src/com/codename1/ui/Toolbar.java index 975a223ce6..2d84743456 100644 --- a/CodenameOne/src/com/codename1/ui/Toolbar.java +++ b/CodenameOne/src/com/codename1/ui/Toolbar.java @@ -31,6 +31,7 @@ import com.codename1.ui.events.ActionEvent; import com.codename1.ui.events.ActionListener; import com.codename1.ui.events.ScrollListener; +import com.codename1.ui.geom.Rectangle; import com.codename1.ui.layouts.BorderLayout; import com.codename1.ui.layouts.BoxLayout; import com.codename1.ui.layouts.Layout; @@ -2530,14 +2531,34 @@ protected void initTitleBarStatus() { if (getUIManager().isThemeConstant("paintsTitleBarBool", false)) { // check if its already added: if (((BorderLayout) getLayout()).getNorth() == null) { - Container bar = new Container(); + Component bar; + if (getUIManager().isThemeConstant("statusBarScrollsUpBool", true)) { + Button btn = new Button(); + btn.setShowEvenIfBlank(true); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent evt) { + Form parent = getComponentForm(); + if (parent != null) { + Component c = parent.findScrollableChild(parent.getContentPane()); + if (c != null) { + c.scrollRectToVisible(new Rectangle(0, 0, 10, 10), c); + } + } + } + }); + bar = btn; + } else { + Container c = new Container(); + c.setSafeArea(true); + bar = c; + } if (getUIManager().isThemeConstant("landscapeTitleUiidBool", false)) { bar.setUIID("StatusBar", "StatusBarLandscape"); } else { bar.setUIID("StatusBar"); } reallocateVerticalPaddingAndMarginsToTop(bar); - bar.setSafeArea(true); addComponent(BorderLayout.NORTH, bar); } } else {