#2324 Can not use nested fwt::Menu in Javascript

SlimerDude Thu 7 Aug 2014

Whenever I try to set the text on a fwt::Menu in Javascript I get the Err:

menu := Menu { text = "Nested"; }

...

TypeError: this.peer.text$ is not a function
  return this.peer.text$(this,it);

I get similar errs for image and mode.

Looking at MenuPeer.js, it starts with this:

/**
 * MenuPeer.
 */
fan.fwt.MenuPeer = fan.sys.Obj.$extend(fan.fwt.WidgetPeer);
...

But given Menu extends from MenuItem, should it not be:

fan.fwt.MenuPeer = fan.sys.Obj.$extend(fan.fwt.MenuItemPeer);

?

andy Thu 7 Aug 2014

Is that the only issue? Can you verify that change and I can fix if looks good.

brian Thu 7 Aug 2014

Are you trying to use multi-level nested menus? If so, then I'm pretty sure that isn't supported in JS, so I'm thinking to get that to work is a lot more work

SlimerDude Thu 7 Aug 2014

Yeah, I'm trying to get the FwtDemo example to work in a broswer... which looks like:

Menu makeMenuBar()
{
  return Menu
  {
    Menu
    {
      text = "File";
      MenuItem { it.text = "Exit"; onAction.add |->| { Env.cur.exit } },
    },

    Menu
    {
      text = "Nested";
      Menu
      {
        text = "Alpha"
        image = folderIcon
        MenuItem { text = "Alpha.1"; onAction.add(cb) },
        Menu
        {
          text = "Alpha.2"
          MenuItem { text = "Alpha.2.I"; onAction.add(cb) },
          ...

But it dies on the first File menu.

Are menu bars not possible in Javascript then?

SlimerDude Thu 7 Aug 2014

I tried hot-patching my fwt.pod with partial success...

makeMenuBar() now seems to work fine but then it dies during MenuPeer.relayout() with:

Uncaught TypeError: Cannot read property 'posOnDisplay' of undefined 

MenuPeer.js: line 185: var pp = this.$parent.posOnDisplay();

And then I'm lost...!

Brian, is that the sort of error / message you'd expect to see with nested Menus?

andy Thu 7 Aug 2014

Promoted to ticket #2324 and assigned to andy

Probably not yet implemented completely.

andy Thu 7 Aug 2014

Renamed from Can not use fwt::Menu in Javascript to Can not use nested fwt::Menu in Javascript

Login or Signup to reply.