This signal is emitted by the default implementation of $highlightedEvent(). |-EXAMPLE POPUP MENU-| |--Start: # First of all we create an array wich will be used to create random colors. %Hex[]=$array(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) class (ws,widget) { #In the constructor we create everything that belong to the single widget. constructor { #Geometry of the widget and setting-up of popupmenu $$->$setGeometry(%X,%Y,100,100) $$->%lay=$new(layout,$$) #Here we generate a cicle to create our labels inside the widget. %i=0 while (%i<10) { $$->%label=$new(label,$$) $$->%label->$settext("Another class by N\&G") #We set our foreground's coulor using the hex arrey in random way. %color=%Hex[$rand(14)]%Hex[$rand(14)]%Hex[$rand(14)]%Hex[$rand(14)]%Hex[$rand(14)]%Hex[$rand(14)] $$->%label->$setforegroundcolor(%color) $$->%label->$setautoresize(1) #We add the label to the widget's popupmenu. $$->%lay->$addwidget($$->%label,%i,0) %i++; } #We make the popupmenu relative to this widget: this is merely demonstrative. #because it creates 25 identical popups. $$->%Popupmenu=$new(popupmenu,$$) #we create the label widget wich will be used as popup's title $$->%Popuptitle=$new(label) $$->%Popuptitle->$settext(<B><U>"Windows Options"</B></U>) $$->%Popuptitle->$setAlignment(Center) #and we add it. %A=$$->%Popuptitle $$->%Popupmenu->$insertwidget(%A) #Here we keep the various IDs in the arrays %Tile[%I]=$$->%Popupmenu->$insertItem("Tile",118) %Cascade[%I]=$$->%Popupmenu->$insertItem("Cascade",115) $$->%Popupmenu->$insertSeparator(3) %Closeactw[%I]=$$->%Popupmenu->$insertItem("Close Active Window",08) %Closeallw[%I]=$$->%Popupmenu->$insertItem("Close All Window",58) $$->$show() privateimpl($$->%Popupmenu,activatedEvent) { %id=$0 %i = 0 #with this cicle we control wich of the items has been called comparing the id given back by the event with our arrays created before; while (%i<20) { if (%id == %Tile[%i]) return %Workspace->$tile() if (%id == %Cascade[%i]) return %Workspace->$cascade() if (%id == %Closeactw[%i]) return %Workspace->$closeactivewindow() if (%id == %Closeallw[%i]) return %Workspace->$closeallwindows() %i ++ } } } #we activate the popup pushing the right mouse button on the widget mousepressevent { if ($0 == 1) $$->%Popupmenu->$exec() } } %Workspace=$new(workspace) %Workspace->$resize(640,480) %I=0 %Cicle=1 while (%I<20) { %X=$rand(500) %Y=$rand(480) %Widget=$new(ws,%Workspace) %I++ } #Let's show! %Workspace->$show |--End.
|