This Question is Answered

15 "helpful" answers available (3 pts)
5 Replies Last post: Mar 10, 2008 10:19 AM by nuitange

MenuPane does not disappear

Mar 9, 2008 3:33 AM

Click to view nuitange's profile Level 1 nuitange 2 posts since
Nov 7, 2007
I make a new control, using TextField and MenuPane.

The contents written down in TextField is shown in MenuPane.

But when MenuPane pop up by "show-adjacent" method with start-traversal?=false, it never disappears.

{curl 5.0 applet}
{curl-file-attributes character-encoding = "utf8"}

{define-class public ListField {inherits TextField}
field private _mp:#MenuPane
field private _dp:TextDisplay

{constructor public {default ...}
{construct-super
{splice ...}}
set self._dp = {TextDisplay}
set self._mp = {MenuPane
self._dp
}
}

{method public {on-focus-in e:FocusIn}:void
{self._mp.show-adjacent
self, {self.get-bounds},
alongside?=false,
start-traversal?=false
}
}

{method public {on-focus-out e:FocusOut}:void
{self._mp.hide}
}

{method public {on-key-press e:KeyPress}:void
set self._dp.value = self.value

}
}


{ListField}


Click to view friedger's profile MVP friedger 108 posts since
Jan 13, 2008
1. Re: MenuPane does not disappear Mar 9, 2008 6:02 AM
Hi Yi,

try detach in the on-focus-out method:

{method public {on-focus-out e:FocusOut}:void
  {self._mp.detach}
}


The hide method of the menu expects that menu travesal has already been started.

Friedger

Click to view friedger's profile MVP friedger 108 posts since
Jan 13, 2008
2. Re: MenuPane does not disappear Mar 9, 2008 6:33 AM
in response to: friedger

My suggested solution somehow leaves a white area that is not re-rendered...

You should also use an event handler on ValueChanged instead of on-key-press


 
 {constructor <b>public</b> {<b>default</b> ...}
    {construct-<b>super</b>
        {splice ...}}
    set self._dp = {TextDisplay}
    set self._mp = {MenuPane
                       self._dp
                   }
    {self.add-event-handler
        {on ValueChanged <b>do</b>
                set self._dp.value = self.value
        }
    }
  }
 
 

Friedger

Click to view Kamal's profile Curl Kamal 149 posts since
Oct 17, 2007
3. Re: MenuPane does not disappear Mar 10, 2008 5:54 AM
Since on FocusIn you are showing the Menu and you want the Menu to disapper by itself, you should pass start-traversal? = true. I guess the documentation should have explained this a little bit.
By the way, is there any particualr reason you choose to pass false?
Click to view Kamal's profile Curl Kamal 149 posts since
Oct 17, 2007
4. Re: MenuPane does not disappear Mar 10, 2008 6:08 AM
By the way, if your situation demads that start-traversal? should be false, then on focus out use the following code:


{method public {on-focus-out e:FocusOut}:void
{if-non-null view = {self._mp.get-view} then
{view.hide} || You can use {view.destroy} too.
}


}


The reason "hide" method does not work is because that there was no MenuManager associated with this MenuPane since you choose not to start the traversal. I guess this should be documented or the hide method should be fixed to close even a non traversing menu.


By the way friedger's solution of "detach" leaves an empty window because the detach method on the MenuPane will detach the MenuPane from the View it is showing in (note that it does not close the View in which the MenuPane is showing), so you see an empty View.

Message was edited by: Kamal

Click to view nuitange's profile Level 1 nuitange 2 posts since
Nov 7, 2007
5. Re: MenuPane does not disappear Mar 10, 2008 10:19 AM
in response to: Kamal
With TextField, RecordView, RecordGrid, and MenuPane, I'm making a new control that is searchable. I call it ListField.

Curl has controls having lists for selection such as DropdownList, ComboBox, ListBox, but they cannot be searchable.

The new control (ListField) has the following functions:
When each letter is entered, the current value of TextField is searched from RecordView.
The search results are shown on RecordGrid in MenuPane, and users can select a item for the value of this new control.

Such a control is most needed particularly in applications which request accurate inputs in shot time.

For this purpose, I wanted to set "start-traverse?" to false.

With your help, I can complete ListField.
Thank you very much.