codenameone / CodenameOne

Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.
https://www.codenameone.com/
Other
1.66k stars 395 forks source link

Combox doesn't allow Y placement at the top #3795

Open ddyer0 opened 2 months ago

ddyer0 commented 2 months ago

The whole way ComboBox works is bizarre, and it's basically impossible to clone and modify it as a whole, because it uses internal variables and apis that are not available outside of package com.codename1.ui

It's also impossible to override the "center y" functionality that's built in. I'd like my menus to top up at the top of the frame. Short of reworking the whole thing, a simple change can provide the "menu at top" functionality.

In "showPopupDialog" add a boolean centerMenu and this clause

                if(listH < formHeight) {
                    // pop up or down?
                    if(centerMenu)
                    {
                        if(top > formHeight / 2) {
                            bottom = formHeight - top;
                            top = top - listH;
                        } else {
                            top +=  getHeight();
                            bottom = formHeight - top - listH;
                        }
                    }
                    else {
                        // leave top at the top
                        bottom = formHeight - top - listH;
                                if(bottom<0) { top += bottom; bottom = 0; }
                    }
                }

Also noted; the various Max(x,0) clauses when calling popupDialog.show are not coordinated, so if any of them fire the presented menu is damaged.

The "ComboDialog" created by createPopupDialog is never shown. AFAIK it is used as a container for an underlying list which is presented by popupDialog.show

shai-almog commented 2 months ago

Yes. It's an old and fragile component. We suggest avoiding it: https://www.codenameone.com/blog/tip-dont-use-combobox.html

ddyer0 commented 2 months ago

Sure, and I'm not suggesting a rewrite - more like one more barnacle on the old hull.