BBjWindow::setReportAllKeyEvents

Description

In BBj 15.00 and higher, this method sets an option to have all controls report keypress events to the window.

Syntax

Return Value

Method

void

setReportAllKeyEvents(boolean report)

Parameters

Variable

Description

report

Specifies whether keypress events should be reported for all controls on the window.
0 = events are not reported
1 = events are reported

Return Value

None.

Remarks

By default, only a small subset of keypress events are reported to the window when text controls have focus.

Example

rem ' BBjWindow::setReportAllKeyEvents

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
title$ = "setReportAllKeyEvents"
window! = sysgui!.addWindow(100,100,250,300,title$,$20090003$)
gosub print
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_KEYPRESS,"keypress")
checkbox! = window!.addCheckBox(101,25,25,200,25,title$,$0004$)
checkbox!.setCallback(checkbox!.ON_CHECK_ON,"on")
checkbox!.setCallback(checkbox!.ON_CHECK_OFF,"off")
text! = window!.addStaticText(102,25,75,200,25,"BBjStaticText",$$)
edit! = window!.addEditBox(103,25,125,200,25,"BBjEditBox",$$)
inpute! = window!.addInputE(104,25,175,200,25,$$,255,"","BBjInputE")
cedit! = window!.addCEdit(105,25,225,200,50,"BBjCEdit",$0004$)
dim event$:tmpl(sysgui)
process_events

eoj:
release

on:
    window!.setReportAllKeyEvents(1,err=*next)
    gosub print
return

off:
    window!.setReportAllKeyEvents(0,err=*next)
    gosub print
return

print:
    print "BBjWindow::getReportAllKeyEvents() = ",
    print window!.getReportAllKeyEvents(err=*next)
return

keypress:
    print fill(72,"=")
    event$ = sysgui!.getLastEventString()
    key=event.id,flags$=event.flags$
    print "Window Keypress: ",hta(event.id$)," Flags: ",
    print hta(event.flags$)+": """+cvs(event.id$,16)+"""",
    if key>255 then print "" else gosub key
    event! = sysgui!.getLastEvent()
    print "getOriginalControl(): ",event!.getOriginalControl()
    print "getKeyChar():",num(event!.getKeyChar())
    print "getKeyCode():",num(event!.getKeyCode()),": ",
    keycode=event!.getKeyCode()
    gosub keycode
    print "isShiftDown(): ",event!.isShiftDown()
    print "isControlDown(): ",event!.isControlDown()
    print "isAltDown(): ",event!.isAltDown()
    print "isCmdDown(): ",event!.isCmdDown()
    print fill(72,"=")
return

key:
    print ": ",
    if asc(and(flags$,$01$)) then print "SHIFT+",
    if asc(and(flags$,$02$)) then print "CTRL+",;key=key+64
    if asc(and(flags$,$04$)) then print "ALT+",
    if asc(and(flags$,$08$)) then print "CMD+",
    print cvs(chr(key),16)
return

keycode:
    keycode$=bin(keycode,2)
    if asc(and(keycode$,$1000$)) then print "SHIFT+",
    if asc(and(keycode$,$2000$)) then print "CTRL+",
    if asc(and(keycode$,$4000$)) then print "ALT+",
    if asc(and(keycode$,$8000$)) then print "CMD+",
    switch dec(and(keycode$,$0fff$))
        case dec($0009$); print "Tab"; break
        case dec($001b$); print "Escape"; break
        case dec($007f$); print "Delete"; break
        case dec($012d$); print "Up arrow"; break
        case dec($012e$); print "Down arrow"; break
        case dec($012f$); print "Right arrow"; break
        case dec($0130$); print "Left arrow"; break
        case dec($0131$); print "Page up"; break
        case dec($0132$); print "Page down"; break
        case dec($0133$); print "Home"; break
        case dec($0134$); print "End"; break
        case dec($0135$); print "Ctrl-Home"; break
        case dec($0136$); print "Ctrl-End"; break
        case dec($0138$); print "Insert"; break
        case dec($0139$); print "Ctrl-Right arrow"; break
        case dec($013a$); print "Ctrl-Left arrow"; break
        case dec($013b$); print "Backtab"; break
        case dec($013e$); print "Keypad 0"; break
        case dec($013f$); print "Keypad 1"; break
        case dec($0140$); print "Keypad 2"; break
        case dec($0141$); print "Keypad 3"; break
        case dec($0142$); print "Keypad 4"; break
        case dec($0143$); print "Keypad 5"; break
        case dec($0144$); print "Keypad 6"; break
        case dec($0145$); print "Keypad 7"; break
        case dec($0146$); print "Keypad 8"; break
        case dec($0147$); print "Keypad 9"; break
        case dec($014b$); print "F1"; break
        case dec($014c$); print "F2"; break
        case dec($014d$); print "F3"; break
        case dec($014e$); print "F4"; break
        case dec($014f$); print "F5"; break
        case dec($0150$); print "F6"; break
        case dec($0151$); print "F7"; break
        case dec($0152$); print "F8"; break
        case dec($0153$); print "F9"; break
        case dec($0154$); print "F10"; break
        case dec($0155$); print "F11"; break
        case dec($0156$); print "F12"; break
        case dec($0174$); print "Keypad *"; break
        case dec($0175$); print "Keypad -"; break
        case dec($0176$); print "Keypad +"; break
        case dec($0177$); print "Keypad /"; break
        case default; print """",chr(dec(and(keycode$,$00ff$))),""" ",keycode; break
    swend
return

See Also

BBjAPI

BBjWindow

Object Variables

BBjKeypressEvent::getOriginalControl

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