Strange behavior when transparent pop-up menu overlaid over text


#1

I’ve run into strange pop-up behavior when overlaying a text field with a transparent pop-up menu.

The text field just has the date field from the current record, formatted with datepattern(. It is overlaid over a different colored rounded rectangle.

04%20AM

This text field is overlaid with a transparent pop-up menu, with a formula that grabs all the possible dates currently in the database:

arraydeduplicate(arraybuild(cr(), "", {datepattern(Date,"MM/DD/YY")+"-"+datepattern(Date,"Day")}),cr())

When you click on the pop-up, the correct dates are in the choices, but the choices also contain the letter ‘A’ at the bottom:

48%20AM

There is no record in the database in which is entered the letter ‘A’. It’s a date field, so I don’t even think that’s possible.

When I remove the underlying differently-colored rounded rectangle, the ‘A’ disappears. I’m just trying to make the text larger in the visible date field while changing the color underlay to make sure the users know that it’s a button.

Is this a known issue?


#2

With the information you have provided I can’t explain your results, I suspect there is some setting of the popup button object we are not seeing that might explain. However, I will suggest that you not use a transparent popup menu button. In Panorama X, I never use transparent buttons of any kind any more. Instead, I just add code to pop up a menu directly to whatever object is being displayed, using the popupclick function. So now you can make any kind of object into a popup menu, a text display object, a rectangle, an image, whatever. Much simpler than using a separate transparent object – dealing with transparent objects is a pain IMHO.


#3

Thanks for the tip on the popupclick statement. That worked. Hadn’t used that one yet.

Make sure you’re trapping for no entry in your code after invoking this–it will enter a null into your target field if you pull off the menu after you click on an object with popupclick in the procedure and you’ve set it up for data entry into a field.


#4

Good tip. I’ve just now edited the example in the help page for this function to make that more clear (it was mentioned in the text, but not really highlighted as it should have been). I also took the opportunity to show how you can use the menu( function to create more complex menus. The new text won’t appear in the help until the next release, but here I’ve included it below:


This statement can be used to produce a pop-up menu at the current mouse position. It is intended that this statement be used in a procedure that is triggered by a button on a form (or any form object that triggers a procedure). The procedure must be triggered on mouse down, not mouse up.

Here is an example that displays a pop-up menu with three colors when the button is clicked.

local colorChoice
popupclick "Red"+cr()+"Green"+cr()+"Blue","Red",colorChoice
if colorChoice = "" return endif // do nothing if user pulled off mouse
// colorChoice now contains the color name
if colorChoice="Red"
    .. do something redish
elseif colorChoice="Green"
    .. do something greenish
elseif colorChoice="Blue"
    .. do something blueish
endif

You can also use the [menu(][] and [menuitem(][] functions to create the menu, as shown in this example. This is more complicated but gives you more control – you can give menu items different colors or styles, or even include submenus in your pop-up menu.

local colorChoice
let colorMenu = menu("Colors")
    menuitem("Red","color","770000")+
    menuitem("Green","color","007700")+
    menuitem("Blue","color","000077")
popupclick colorMenu,"Red",colorChoice
if colorChoice = "" return endif // do nothing if user pulled off mouse
// colorChoice now contains the color name
if colorChoice="Red"
    .. do something redish
elseif colorChoice="Green"
    .. do something greenish
elseif colorChoice="Blue"
    .. do something blueish
endif

Oh, you had me scared for a moment, thought there was a bug. “Null” has a definite meaning to a C programmer that is different than empty text (""). So if there are any other C programmers out there, this function doesn’t actually return null, it returns empty text. But Joe is correct, if you plugged the result directly into a field without checking for empty, you would zap the field contents if you don’t check for empty. So don’t put the result directly into a field, put it into a variable, check the variable for empty, then only update the field if not empty. So here is an example of the correct way to do it.

local colorChoice
popupclick "Red"+cr()+"Green"+cr()+"Blue",ColorField,colorChoice
if colorChoice <> ""
    ColorField = colorChoice
endif

#5

Sorry about the ‘null-empty text’ confusion…and Jim’s suggestion is what I had done–enter the choice into a variable, test the variable for empty text, then enter the variable contents into the field if it isn’t empty.

Works great! Thanks, Jim.


#6

You had no way of knowing about that, it’s a pretty technical topic! I just mentioned it for everyone’s general education.

I figured you had already done it, I just wanted to clarify for anyone else following along that hadn’t already been down the road you had just travelled, or for someone that turns up this topic in a search sometime in the future :slight_smile: