Help: Bug in VSW 3.1 - can't add menu on the fly 
Author Message
 Help: Bug in VSW 3.1 - can't add menu on the fly

Hi all,

I think I have found a bug in the menus behavior in VS 3.1. When I add a menu
to an open window, and this menu contains a separator, the menu opens
on the whole screen height no matter how many items there are. I attach
a code for a simple window that has buttons for creating 'good' and
'bad' menus. I wonder if it is Window Builder or Smalltalk problem
and if it can be fixed.

Thanks,
Simon

 _________                Simon (Vsevolod ILyushchenko)
|       x |

|_________|   (For all normal mail)

Disclaimer: This is not me. This is just my mailer talking to your mailer...

ViewManager subclass: #TestWindow
  instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries:
    ' ColorConstants OperatingSystemConstants '   !

!TestWindow class methods !

wbBasicVersion

    "Private - Answer the WindowBuilder Pro version.
        Generated in: Visual Smalltalk 3.1.0 Win32"

    ^3.1! !

!TestWindow methods !

createMenus: aPane

    "WARNING!! This method was automatically generated by
    WindowBuilder. Code you add here which does not conform to
    the WindowBuilder API will probably be lost the next time
    you save your layout definition."

    #generated.
    aPane menuWindow
        yourself;
        addMenu: (
            Menu new
                title: 'Test';
                owner: self
        )!

createViews

    "WARNING!! This method was automatically generated by
    WindowBuilder. Code you add here which does not conform to
    the WindowBuilder API will probably be lost the next time
    you save your layout definition."

    | button1 button2 mainView xDU yDU |

    #generated.
    xDU := (SysFont width + 1 roundTo: 2) / 4.
    yDU := SysFont height / 8.
    mainView := self topPaneClass new.

        "Temporary Variables"
    button1 := Button new.
    button2 := Button new.

    mainView
        owner: self;
        setName: 'mainView';
        labelWithoutPrefix: 'New Window';
        noSmalltalkMenuBar;
        backColor: Color gray;
        framingBlock:
            (LayoutFrame new
                leftRatio: 1/2; leftInset: -374/5 * xDU;
                topRatio: 1/2; topInset: -50 * yDU;
                rightRatio: 1/2; rightInset: -376/5 * xDU;
                bottomRatio: 1/2; bottomInset: -50 * yDU).
    self addView: mainView.

    button1
        owner: self;
        when: #clicked send: #menuWith to: self;
        framingBlock:
            (LayoutFrame new
                leftRatio: 0; leftInset: 152/5 * xDU;
                topRatio: 0; topInset: 48/5 * yDU;
                rightRatio: 0; rightInset: -112 * xDU;
                bottomRatio: 0; bottomInset: -24 * yDU);
        contents: 'Menu with separator';
        startGroup;
        noTabStop;
        font: SysFont.
    mainView addSubpane: button1.

    button2
        owner: self;
        when: #clicked send: #menuWithout to: self;
        framingBlock:
            (LayoutFrame new
                leftRatio: 0; leftInset: 128/5 * xDU;
                topRatio: 0; topInset: 232/5 * yDU;
                rightRatio: 0; rightInset: -592/5 * xDU;
                bottomRatio: 0; bottomInset: -304/5 * yDU);
        contents: 'Menu without separator';
        startGroup;
        noTabStop;
        font: SysFont.
    mainView addSubpane: button2.

    self createMenus: mainView!

doNothing!

menuWith

    "Callback for the #clicked event in <Unnamed> [Button].
        (Generated by WindowBuilder Pro)"

    |menu newMenu|

         menu := self menuTitled: 'Test'.
         menu deleteAll.
        newMenu := Menu labels: 'Bad menu\nBad menu 2' replaceEscapeCharacters lines: #(1) selectors: #(doNothing doNothing).
         newMenu items indexedDo: [:index :item|
                     menu insertItemDynamically: item label selector: item selector atIndex: index].

!

menuWithout

    "Callback for the #clicked event in <Unnamed> [Button].
        (Generated by WindowBuilder Pro)"

    |menu newMenu|
         menu := self menuTitled: 'Test'.
         menu deleteAll.
        newMenu := Menu labels: 'Good menu\nGood menu 2' replaceEscapeCharacters lines: #() selectors: #(doNothing doNothing).
         newMenu items indexedDo: [:index :item|
                     menu insertItemDynamically: item label selector: item selector atIndex: index].

! !



Mon, 22 Feb 1999 03:00:00 GMT  
 Help: Bug in VSW 3.1 - can't add menu on the fly

Quote:

> I think I have found a bug in the menus behavior in VS 3.1. When I add a menu
> to an open window, and this menu contains a separator, the menu opens
> on the whole screen height no matter how many items there are.

I think the main problem is the use of #insertItemDynamically:selector:atIndex:
which is *only* intended for use with regular menu items. It is not designed
to work with separators. As such, you probably need to try a different
approach. The Menu class has specific protocols for dealing with separators
(e.g., #appendSeparator).

-Eric Clayberg

Objectshare - a division of ParcPlace   http://www.objectshare.com



Mon, 22 Feb 1999 03:00:00 GMT  
 Help: Bug in VSW 3.1 - can't add menu on the fly

Quote:

> > I think I have found a bug in the menus behavior in VS 3.1. When I add a menu
> > to an open window, and this menu contains a separator, the menu opens
> > on the whole screen height no matter how many items there are.

> I think the main problem is the use of #insertItemDynamically:selector:atIndex:
> which is *only* intended for use with regular menu items. It is not designed
> to work with separators. As such, you probably need to try a different
> approach. The Menu class has specific protocols for dealing with separators
> (e.g., #appendSeparator).

Eric,

Thanks for answering, but #appendSeparator behaves really weird.
I tried to do this: (I will truncate the long message names)

    menu insertItemDynamically: 'AAA' ... atIndex: 1.
    menu appendSeparator.
    menu insert: 'BBB' at: 2.
I got
    AAA
    ___

Then I tried
    menu insert: 'BBB' at: 3
and
    menu insert: 'BBB' at: 1
Both produce
    AAA
    BBB

Finally, I wrote
    menu insert: 'BBB' at: 2.
    menu insert: 'CCC' at: 3.
Then I got
    AAA
    ___
    CCC

I would not call it very intuitive.

Simon

 _________                Simon (Vsevolod ILyushchenko)
|       x |

|_________|   (For all normal mail)

Disclaimer: This is not me. This is just my mailer talking to your mailer...



Tue, 23 Feb 1999 03:00:00 GMT  
 Help: Bug in VSW 3.1 - can't add menu on the fly

Quote:

> Hi all,

> I think I have found a bug in the menus behavior in VS 3.1. When I add a menu
> to an open window, and this menu contains a separator, the menu opens
> on the whole screen height no matter how many items there are. I attach
> a code for a simple window that has buttons for creating 'good' and
> 'bad' menus. I wonder if it is Window Builder or Smalltalk problem
> and if it can be fixed.

The method you use in your code is from OSI. I do not exactly know
what the method is for. It is not used in our Smalltalk versions
(3.0.1, 3.1, 3.1.1).

Quote:
> menuWith

>     "Callback for the #clicked event in <Unnamed> [Button].
>         (Generated by WindowBuilder Pro)"

>     |menu newMenu|

>          menu := self menuTitled: 'Test'.
>          menu deleteAll.
>         newMenu := Menu labels: 'Bad menu\nBad menu 2' replaceEscapeCharacters lines: #(1) selectors: #(doNothing doNothing).
>          newMenu items indexedDo: [:index :item|
>                      menu insertItemDynamically: item label selector: item selector atIndex: index].

The above solution does not work. I tried it. But thee is way to do
it. Use insertItem:selector:accelKey:accelBits:after: and
insertSeparatorAfter: to manipulate a menu in VS or VSE.

The above method would look like the one below

menuWith

        "Add some menu items to a menu"

        |menu newMenu|
        menu := self menuTitled: 'Test'.
        menu deleteAll.

        menu
          insertItem: (menu fixUnderScoreChar: &Bad Menu)
                            selector: #doNothing
                            accelKey: nil
                            accelBits: nil
                            after: 0.

        menu insertSeparatorAfter: 1.

        menu
          insertItem: (menu fixUnderScoreChar: Bad &Menu 2)
                            selector: #doNothing
                            accelKey: nil
                            accelBits: nil
                            after: 3.

This will work

        Clemens Hoffmann



Tue, 23 Feb 1999 03:00:00 GMT  
 Help: Bug in VSW 3.1 - can't add menu on the fly

Quote:

> Thanks for answering, but #appendSeparator behaves really weird.
> I tried to do this: (I will truncate the long message names)

I mentioned #appendSeparator only as an example of one of Menu's
protocols for handling separators. There are others like
#insertSeparatorAfter: that might be more suitable in this situation.

-Eric Clayberg

Objectshare - a division of ParcPlace   http://www.objectshare.com



Tue, 23 Feb 1999 03:00:00 GMT  
 Help: Bug in VSW 3.1 - can't add menu on the fly

Quote:
> > I think I have found a bug in the menus behavior in VS 3.1. When I add a menu
> > to an open window, and this menu contains a separator, the menu opens
> > on the whole screen height no matter how many items there are. I attach
> > a code for a simple window that has buttons for creating 'good' and
> > 'bad' menus. I wonder if it is Window Builder or Smalltalk problem
> > and if it can be fixed.

> The method you use in your code is from OSI. I do not exactly know
> what the method is for. It is not used in our Smalltalk versions
> (3.0.1, 3.1, 3.1.1).
> <skip>

> The above solution does not work. I tried it. But thee is way to do
> it. Use insertItem:selector:accelKey:accelBits:after: and
> insertSeparatorAfter: to manipulate a menu in VS or VSE.

> The above method would look like the one below

Clemens,

Thanks for your answer.
But did you actully tried it out with this window? In my image, #insertItem:...
does not work at all (except at the creation time), and #insertSeparatorAfter:
works just as #appendSeparator (eating away one line).

Not that it is a problem in my work, but I am puzzled.

Simon

 _________                Simon (Vsevolod ILyushchenko)
|       x |

|_________|   (For all normal mail)

Disclaimer: This is not me. This is just my mailer talking to your mailer...

- Show quoted text -

Quote:
> menuWith

>     "Add some menu items to a menu"

>     |menu newMenu|
>     menu := self menuTitled: 'Test'.
>     menu deleteAll.

>     menu
>           insertItem: (menu fixUnderScoreChar: &Bad Menu)
>                             selector: #doNothing
>                             accelKey: nil
>                             accelBits: nil
>                             after: 0.

>     menu insertSeparatorAfter: 1.

>     menu
>           insertItem: (menu fixUnderScoreChar: Bad &Menu 2)
>                             selector: #doNothing
>                             accelKey: nil
>                             accelBits: nil
>                             after: 3.

> This will work

>     Clemens Hoffmann




Tue, 23 Feb 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. VO- help: how change menu text on the fly

2. adding program to windows 'programs' menu

3. Using CGI module with 'canned queries'

4. MS Fortran 5.1 HELP doesn't work in MSW 3.1 DOS BOX

5. What's this help in VSW?

6. Q:foreach/menu add command quirk/bug

7. TopSpeed - ODBC 3.1???? HELP HELP HELP

8. add choices to drop down menu's

9. Adding to the system menu on 'Windows

10. adding-removing menu entry's

11. Can't add to system menu on NT

12. Can't add items to system menu on W98

 

 
Powered by phpBB® Forum Software