DisableMenuItem issue?

Linux specific forum
dougmo52usr
User
User
Posts: 67
Joined: Mon Jul 18, 2016 6:43 pm

DisableMenuItem issue?

Post by dougmo52usr »

I am using CreatePopupMenu to display a menu of available serial ports. I save the name of the selected serial port in a variable. The next time I build the menu, I place a checkmark on the serial port that was selected last time. All of that works.

However, I am trying to disable one of the menu entries and I see no evidence that disable worked. The menu item is not grayed, and I can still click it.

The line, DisableMenuItem(PopupMenuOfCtlPorts,MenuItem,Bool(CommPortSim = thisSerialPort)) compares two strings, and if they are equal should disable one of the menu items.

I tried replacing Bool(CommPortSim = thisSerialPort) with a 1, and I expected all of the menuitems to disable in the foreach. It doesn't seem to happen. They are not grayed and are clickable.

Anything obvious?

Code: Select all

      
      PopupMenuOfCtlPorts = CreatePopupMenu(#PB_Any)
      ListCommPorts(ListOfCommPorts())
      MenuItem = #MenuItemCtlFirstPort
      ForEach ListOfCommPorts()
        thisSerialPort = ListOfCommPorts()
        ; add the comm port to the menu
        MenuItem(MenuItem,thisSerialPort)
        ; if the simulator has claimed it, disable it
        DisableMenuItem(PopupMenuOfCtlPorts,MenuItem,Bool(CommPortSim = thisSerialPort))
        ; if it was the last one selected, check it
        SetMenuItemState(PopupMenuOfCtlPorts,MenuItem,Bool(CommPortCtl = thisSerialPort))
        BindMenuEvent(PopupMenuOfCtlPorts,MenuItem,@onPortSelected())
        MenuItem = MenuItem + 1
     Next
     DisplayPopupMenu(PopupMenuOfCtlPorts,Window_0)