I try to add a context menu to items in a ComboBox to enable removing items
from the box - without success. The menupane does not get the
focus/traversal. context-menu does not work at all. Therefore I control the
popup of the menu manually.

Any ideas?

Friedger

{let lm = {DefaultListModel
              "A", "B", "D", "C"
          }}
{ComboBox
    data-model = lm,
    list-item-creation-proc =
        {proc {val:any}:ListValueItem
            {return
                {ListValueItem val,
                    label =
                        {Frame val,
                            width = {add-stretch},
                            background = "silver",
                            opaque-to-events? = true,
||--                            {context-popup
||--                                menu-pane = {MenuPane
||--                                    {MenuAction label = "remove-1",
||--                                        {on Action do
||--                                            {output "xxx"}
||--                                            let pos = {lm.find val}
||--                                            {if  pos >= 0 then
||--                                                {lm.remove pos}
||--                                            }
||--                                        }
||--                                    }
||--                                }
||--                            },
                            {on e:PointerPress at f:Frame do
                                    let m  = {MenuPane
                                                 {MenuAction label =
"remove-2",
                                                     {on Action do
                                                         let pos = {lm.find
val}
                                                         {if  pos >= 0 then
                                                             {lm.remove pos}
                                                         }
                                                     }
                                                 }
                                             }
                                {m.show-adjacent
                                    f,
                                    {f.layout.get-cell-bounds},
                                    alongside?=false,
                                    start-traversal?=true
                                }
||--                                {f.release-key-focus}
||--                                {f.request-key-focus}
||--                                    {{get-gui-manager}.grab-pointer m}
||--                                {output
e.can-end-implicit-pointer-grab?}
||--                                {dump {get-current-menu-manager}}
||--                                {e.continue-implicit-pointer-grab m}
||-- 
{{get-current-menu-manager}.continue-implicit-pointer-grab m}
                            }
                        }
                }
            }
        }
}


*******************************************
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]

Reply via email to