PopupMenu Refresh Question


Lets put this example into play so my question has context :slight_smile:

I have a Sub (SUB-A) that does something. I can call this Sub from a contextual menu AND from a PopUp Menu. My popup menu is coded to show me “100%” in it’s open event.

My question is that when I call SUB-A with a value of 150% from the contextual menu I want to refresh the Popupmenu to now reflect 150%

I have tried to send a control.refresh from the contextual menu after it passed the values to SUB-A but no luck. It seems that the “refresh” doesn’t trigger the Popupmenu’s Change nor Open events. If I could find an event that is effected I would like something like this to occur.

  Dim DataPop as String
  Dim counter,last as Integer
  For counter=1 to last
    me.addRow NthField(DataPop,",",counter)

  if CampusMapWindow.CampusMapCanvas1.ZoomFactor  = 1.50 then
    me.ListIndex = 5
    me.ListIndex = 7 // Set Starting Zoom at 100% (normal view)
  end if

Thanks in advance!

put a break point in your if statement & see if it ever goes into the first condition
I suspect it doesn’t because of how floating point values work

Thanks Norman. I’ll try shortly.

Ok so the if statement is only processed during the application startup. The “refresh” action on the contextual menu fires and then the if statement in the Zoompick Popupmenu never is processed. I have tried putting that if statement block of code from above in the zoompick popupmenu open and Change. No dice.

I wish we had a “Value” property to change instead of only having a .text property on the Popupmenu. That way I could change the value and then refresh to have the control do what I need.

elseif hitItem.Text = "Zoom 275%" then
      // 275% Zoom
      me.mObjectZoom(2.75, "275%")

If you have any other ideas I am game :slight_smile: Thanks again!

Try Listindex or Text
But you really shouldn’t have to refresh it if you set listindex to a different value

I did, but I will try it from a different direction again. Thanks Norman!

What is it you’re trying to do ?
Refresh doesn’t trigger the Popupmenu’s Change nor Open events - its not supposed to.

Setting the listindex will trigger the change event
But there’s no method that does “find the index of the row that that has this text label & set your list index to that” which sounds like what you want
I thin an event really isnt what you need here

However a quick subclass of popupmenu with a method could do this
Create a new subclass & add a method

SetListIndexByText(theText as string)
  dim nItems as integer = Me.ListCount-1
  For i as integer =0 to nitems
    if me.List(i) = theText then
      me.Listindex = i
    end if
  me.listindex = -1

me.listindex = -1

Then set the popup menu to use this as the super class

Then in your code you can do

elseif hitItem.Text = "Zoom 275%" then // 275% Zoom me.mObjectZoom(2.75, "275%") CampusMapWindow.ZoomPick.SetListIndexByText( hitItem.Text )

assuming your contextual menus & the popup use the same textual labels

If they dont then you might want to swap this code to use tags and the contextual menu & the popup use the same tags to mean the same things

Thank you Norman… That should be exactly what I was trying to do, but I just couldn’t myself :slight_smile: Thank you!