On the fly hiding of MenuItems from Menubuttons.

Remco_ReinkingRemco_Reinking Member Posts: 74
edited 2010-09-17 in NAV Tips & Tricks
In stead of making two menu buttons that are placed on top of each other and depending on some conditions wich one should be visible and thereby offering the user other menu items there is an other way to do this.

The property PushAction together with InvalidActionAppearance will do the trick.
See sample code form for the "how to"
This only works when the "normal Lookup behaviour" is not needed.
OBJECT Form 99998 TestFormpje
{
  OBJECT-PROPERTIES
  {
    Date=17-09-10;
    Time=10:03:18;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    Width=8030;
    Height=3740;
    LookupMode=Yes;
    OnOpenForm=BEGIN
                 SomeCondition := CONFIRM('With the extra menuItem?');
                 CurrForm.LOOKUPMODE := SomeCondition;
               END;

    OnQueryCloseForm=BEGIN
                       IF MenuBtnPushed THEN // Dont close the form.
                       BEGIN
                         MenuBtnPushed := FALSE;
                         EXIT( FALSE);
                       END;
                     END;

  }
  CONTROLS
  {
    { 1000000000;MenuButton;5610;2860;2200;550  ;CaptionML=NLD=&Functies;
                                                 Menu=MENUITEMS
                                                 {
                                                   { ID=1000000018;
                                                     CaptionML=NLD=Switch visibility;
                                                     OnPush=BEGIN
                                                              SomeCondition := NOT SomeCondition;
                                                              CurrForm.LOOKUPMODE := SomeCondition;
                                                            END;
                                                             }
                                                   { ID=1000000019;
                                                     PushAction=LookupOK;
                                                     InvalidActionAppearance=Hide;
                                                     CaptionML=NLD=Visible on Condition;
                                                     OnPush=BEGIN
                                                              MenuBtnPushed := TRUE;
                                                              DoWhatYouWantToDoAtThisPlace;
                                                            END;
                                                             }
                                                 }
                                                  }
    { 1000000020;CommandButton;770;2860;2200;550;HorzGlue=Right;
                                                 VertGlue=Bottom;
                                                 Default=Yes;
                                                 PushAction=LookupOK;
                                                 InvalidActionAppearance=Hide }
    { 1000000021;CommandButton;3190;2860;2200;550;
                                                 HorzGlue=Right;
                                                 VertGlue=Bottom;
                                                 Cancel=Yes;
                                                 PushAction=LookupCancel;
                                                 InvalidActionAppearance=Hide }
  }
  CODE
  {
    VAR
      MenuBtnPushed@1000000000 : Boolean;
      SomeCondition@1000000001 : Boolean;

    PROCEDURE DoWhatYouWantToDoAtThisPlace@1000000000();
    BEGIN
      // BigFunction here...
      MESSAGE('Did something.');
    END;

    BEGIN
    END.
  }
}


Sign In or Register to comment.