Stupid popupmenu question

Perhaps you can remove these empty rows after they are added?

E.g.:
for i as integer=me.RowCount-1 downto 0
if me.row(i)=“” then me.RemoveRow i
next

(I tried to remember API1 syntax, so you may have to adjust).

Since I’ve not experienced the issue you’re seeing, I don’t know what the rows actually contain. I’m assuming they’re an empty string, but you may first check yourself (inspect the content of an empty row in the debugger) and then replace the “” value in the code above to the one you find.
HTH.

The project loads and run onm1 MacBookPro with Monterey 12.5.1 and works fine.

Sorry for your troubles.

BTW: I removed the parens and run: works fine too…
You may try to do that, who knows ?

NB: I removed the parens (even the open one) and it worked…


me.addrow"Saskatchewan"

Besides Tim’s suggestion of using a timer!
Supposing provstate has got a change event, I’d try adding to the window a ‘isLoading’ property, then:

isLoading = true
if me.ListIndex = 0 then
provstate.DeleteAllRows
etc.
elseif me.ListIndex = 1 then
provstate.DeleteAllRows
etc.
end if
isLoading = false

Then in the change event of provstate:
if isLoading then return

Thanks for the tips, guys. I’ll give those try and see how it goes.

But this code misses many possibilities…

Try this:

 provstate.DeleteAllRows
select case me.ListIndex
case 0
  provstate.addrow("Ontario")
  provstate.addrow("Quebec")
  provstate.addrow("Manitoba")
  provstate.addrow("Saskatchewan")
  provstate.addrow("Alberta")
  provstate.addrow("British Columbia")
  provstate.addrow("Nova Scotia")
case 1 
  provstate.addrow("Alabama")
  provstate.addrow("Alaska")
  provstate.addrow("Arizona")
  provstate.addrow("Arkansas")
  provstate.addrow("California")
  provstate.addrow("Colorado")

case else
  provstate.addrow("So.. something else going on!")
end select
  provstate.ListIndex = 0

Thank you, Jeff. I changed my code to use case awhile ago, and it made no difference. As per suggestions earlier in the thread, could this be a linux/old Xojo version issue?..and why would the list of states appear correctly if it’s a shortened list rather than all 50?

I’d say because the list doesn’t contain what you think it does.
But if you have exactly 50 lines of code to populate it, that can’t be it.

For debugging purposes, maybe create a method:

Add_to_provstate(s as string)

find all provstate.addrow() and replace with Add_to_provstate()

In that, debug the provstate.listcount
The first call should return 1… does it, or do you get a mysterious number?

Maybe provstate.DeleteAllRows isnt working properly
Try switching to

while provstate.listcount > 0
provstate.removerow(0)
wend

There are exactly 50 addrow statements to populate the list. I tried your deleteallrows alternative, and that produces the same blank rows. I’ll try your suggestion for using a method after I get a wee bit of shut-eye. It’s been a very long night. Thank you again.

This can take a long time, but in the Documentation web site,you can read the Release Notes since 2013 (and even earlier): search there if this bug was removed …

Release Notes

If you find nothing in the Release Notes (I tried to Google, but…)…
Can you download Xojo current version (1) and check with it if the bug still here ?

(1) Using both PopupMenu and DesktopPopupMenu…

My suggestion doesn’t work for you?

Hi Arnaud. RowCount doesn’t exist in 2019r1, and the only thing I could think to use was Count. I keep getting the error saying that “row” doesn’t exist. Sorry if I’m missing something obvious, new business startup happening and my brain is full. LOL

Hi Jeff. It seems sleep didn’t help my brain…I don’t understand what you want me to do inside the method, and how do I debug provstate.listcount?

Hi Emile. I may try that, I’m just loathe to undo what the newer version does when it takes over my associations. Besides, if the new version does have the bug fixed, it doesn’t help me since I don’t have $$$ to upgrade.

But you will know the bug was removed…

Also… did you try to use the States codes instead of the States Full Names ?
(MN for Minnesota)
It may be a matter of used RAM or cummulative length of string or…

To me, we need to find out where the extra lines are coming from.

The first step would be to issue the DeleteAllRows command, and then DO NOTHING ELSE.
If you do that, do you still have blank rows?
If so, add a message box to display the row count

msgbox cstr(provstate.listcount)

… eg you may be able to see blank rows, but are they really there, or is it just failing to refresh?

IF there are blank rows after the deleteallrows, then it’s a Xojo bug.
We can come back to that.

IF THERE ARE NO BLANK ROWS after the DeleteAllRows, then the next question is ‘where do the blank rows come from?’
My idea is to find all places where you currently have provstate.addrow
and use a method instead

The method still ‘just’ does an addrow.

Public   Sub  AddrowReplacement(s as string)
provstate.addrow s
end sub

But you can quickly add code in that to check ‘how it is going’

Public   Sub  AddrowReplacement(s as string)
dim rowsSoFar as integer = provstate.listcount
provstate.addrow s

if provstate.listcount <> rowsSoFar +1 then
msgbox "Added one row but an extra one has appeared!"
end if 

end sub
1 Like

Thank you so much for taking the time help, Jeff. I made the changes you mentioned above, and still have the same result, but there were no msgboxes popping up. Then I wondered if the single blank “row” at the top & bottom of the list is just a placeholder for the list scrollers…especially since clicking on either one of them doesn’t select anything in the list or result in any odd behaviour.
If this is the case, you are all well within your rights to nuke my house. :wink:

But this doesn’t explain why a popup menu adds a whole pile of blank rows (which is why I switched to a combobox). Incidentally, I’m not the only one to see this behaviour in popup menus when using Xojo for linux.

I’ve managed to write the code for API1. What about this?

for i as integer=me.ListCount-1 downto 0
if me.List(i)=“” then me.RemoveRow i
next

(still in an attempt to remove the empty rows after they’ve appeared)

I dont think he has any now.
By the sounds of it (lots of guessing going on here as we can’t see the code) , the original problem was a popupmenu not a listbox.
Now it IS a listbox, there are not lots of empty rows.
Been trying to fix the wrong problem.
If it works with a listbox, that’ll do I guess

Is a listbox and a combobox somehow the same thing? My understanding is that a combobox (which is what I’m using) inherits from a popup menu.