CodenameOne icon indicating copy to clipboard operation
CodenameOne copied to clipboard

Combox doesn't allow Y placement at the top

Open ddyer0 opened this issue 11 months ago • 2 comments

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

ddyer0 avatar Mar 11 '24 07:03 ddyer0

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

shai-almog avatar Mar 12 '24 02:03 shai-almog

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

ddyer0 avatar Mar 12 '24 17:03 ddyer0