BBjMDI::setForwardMenuAccelerators

Description

In BBj 6.0 and higher, this method configures whether keystrokes are forwarded by the window argument to the BBjMDI parent window for menu accelerator consideration.

Syntax

Return Value

Method

void

setForwardMenuAccelerators(BBjTopLevelWindowwindow, boolean forwardKeys)

Parameters

Variable

Description

window

The window on which to configure the forwarding behavior.

forwardKeys

Specifies whether the window argument should forward its keystrokes for consideration as menu accelerators on the MDI Parent window.

0 = Do not forward keys.

1 = Forward keys for menu accelerator consideration

Return Value

None.

Remarks

The value of BBjMDI::getDefaultForwardMenuAccelerators() at the creation time the window argument determines the initial value of this property.

Example

sysgui = unt
open(sysgui)"X0"
api! = BBjAPI()
mdi! = api!.getMDI()

rem '
rem ' If we don't have extra arguments, go to the PARENT's setup code.
if (ARGC = 1) then GOSUB SETUP_PARENT else GOSUB SETUP_CHILD FI
process_events

SETUP_CHILD:
    messagePrefix$ = "Child "
    sg! = api!.getSysGui()
    win! = sg!.addWindow(1, 100, 100, 400, 300, "Test", $00010083$)
    win!.setCallback(api!.ON_CLOSE, "CHILD_APP_CLOSE")
    bar! = win!.addMenuBar()
    GOSUB ADD_FILE_SAVE_MENU
    forwarding = mdi!.getForwardMenuAccelerators(win!)
    text$ = "Forwarding Menu Accelerators: "
    checkBox! = win!.addCheckBox(101, 10, 10, 120, 20, text$)
    checkBox!.setSelected(forwarding)
    checkBox!.setCallback(api!.ON_CHECK_ON, "CHILD_BUTTON")
    checkBox!.setCallback(api!.ON_CHECK_OFF, "CHILD_BUTTON")
return

SETUP_PARENT:
    messagePrefix$ = "Parent "

    rem 'create an MDI Window
    mdi!.createMDIWindow(350, 50, 800, 600, "MDI Window")

    rem 'Add a menubar with a "File" menu and "New", "Save", and "Quit" menu items
    bar! = mdi!.addMenuBar()
    GOSUB ADD_FILE_SAVE_MENU

    rem ' Now add a New and a Quit menu too.
    newItem! = fileMenu!.addMenuItem(-103, "New")
    newItem!.setAccelerator($204E$); REM Ctrl-N
    newItem!.setCallback(api!.ON_MENU_ITEM_SELECT, "PARENT_NEW")
    quitItem! = fileMenu!.addMenuItem(-102, "Quit")
    quitItem!.setAccelerator($2051$); REM Ctrl-Q
    quitItem!.setCallback(api!.ON_MENU_ITEM_SELECT, "PARENT_APP_CLOSE")
    mdi!.setCallback(api!.ON_CLOSE, "PARENT_APP_CLOSE")
    mdi!.setVisible(1)

    rem ' Start child process
    cmdline! = BBjAPI().getConfig().getCurrentCommandLineObject()
    cmdline!.setProgramArgs("child")
    BBjAPI().newBBjSession(cmdline!)

    rem ' Done with SETUP_PARENT
return

rem ' Shared code for adding a file menu and setting the callback for SAVE.
rem ' Requires a menubar to be in the bar! variable. Puts a "File" menu in
rem ' the fileMenu! variable.
ADD_FILE_SAVE_MENU:
    fileMenu! = bar!.addMenu(-101, "File")
    saveItem! = fileMenu!.addMenuItem(-102, "Save")
    saveItem!.setAccelerator($2053$); REM Ctrl-S
    saveItem!.setCallback(api!.ON_MENU_ITEM_SELECT, "SAVE_CALLBACK")
return

rem ' ***********************************************
rem ' ***************** Callbacks *******************
rem ' ***********************************************
rem ' ******************** Shared callbacks ************************
SAVE_CALLBACK:
    PRINT messagePrefix$ + "Save"
return

rem ' ******************** Children callbacks ************************
CHILD_BUTTON:
    mdi!.setForwardMenuAccelerators(win!, ! mdi!.getForwardMenuAccelerators(win!))
return

CHILD_APP_CLOSE:
release

rem ' ******************** Parent callbacks ************************
PARENT_NEW:
    PRINT "Parent New"
return

PARENT_APP_CLOSE:
    res= mdi!.closeAll(0); goto LAB
LAB: release

See Also

BBjAPI

BBjMDI

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.