void TProgram::handleEvent( TEvent& event ) { if( event.what == evKeyDown ) { char c = getAltChar( event.keyDown.keyCode ); if( c >= '1' && c <= '9' ) { // Bug Fix #TV2B-39 -------------------------------------- if(canMoveFocus()) //<--- Check valid first. { if( message(deskTop, evBroadcast, cmSelectWindowNum, (void *)(c - '0')) != 0 ) clearEvent( event ); } else clearEvent( event ); } // end of bug-fix ---------------------------------------- } TGroup::handleEvent( event ); if( event.what == evCommand && event.message.command == cmQuit ) { endModal( cmQuit ); clearEvent( event ); } }
void TProgram::handleEvent( TEvent& event ) { if( event.what == evKeyDown ) { char c = getAltChar( event.keyDown.keyCode ); if( c >= '1' && c <= '9' ) { if( message( deskTop, evBroadcast, cmSelectWindowNum, (void *)(c - '0') ) != 0 ) clearEvent( event ); } } TGroup::handleEvent( event ); if( event.what == evCommand && event.message.command == cmQuit ) { endModal( cmQuit ); clearEvent( event ); } }
void TMenuView::handleEvent( TEvent& event ) { if( menu != 0 ) switch (event.what) { case evMouseDown: do_a_select(event); break; case evKeyDown: if( findItem(getAltChar(event.keyDown.keyCode)) != 0 ) do_a_select(event); else { TMenuItem *p = hotKey(event.keyDown.keyCode); if( p != 0 && commandEnabled(p->command)) { event.what = evCommand; event.message.command = p->command; event.message.infoPtr = 0; putEvent(event); clearEvent(event); } } break; case evCommand: if( event.message.command == cmMenu ) do_a_select(event); break; case evBroadcast: if( event.message.command == cmCommandSetChanged ) { if( updateMenu(menu) ) drawView(); } break; } }
ushort TMenuView::execute() { Boolean autoSelect = False; menuAction action; char ch; ushort result = 0; TMenuItem *itemShown = 0; TMenuItem *p; TMenuView *target; TRect r; TEvent e; current = menu->deflt; do { action = doNothing; getEvent(e); switch (e.what) { case evMouseDown: if( mouseInView(e.mouse.where) || mouseInOwner(e) ) { trackMouse(e); if( size.y == 1 ) autoSelect = True; } else action = doReturn; break; case evMouseUp: trackMouse(e); if( mouseInOwner(e) ) current = menu->deflt; else if( current != 0 && current->name != 0 ) action = doSelect; else action = doReturn; break; case evMouseMove: if( e.mouse.buttons != 0 ) { trackMouse(e); if( !(mouseInView(e.mouse.where) || mouseInOwner(e)) && mouseInMenus(e) ) action = doReturn; } break; case evKeyDown: switch( ctrlToArrow(e.keyDown.keyCode) ) { case kbUp: case kbDown: if( size.y != 1 ) trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbDown)); else if( e.keyDown.keyCode == kbDown ) autoSelect = True; break; case kbLeft: case kbRight: if( parentMenu == 0 ) trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbRight)); else action = doReturn; break; case kbHome: case kbEnd: if( size.y != 1 ) { current = menu->items; if( e.keyDown.keyCode == kbEnd ) trackKey(False); } break; case kbEnter: if( size.y == 1 ) autoSelect = True; action = doSelect; break; case kbEsc: action = doReturn; if( parentMenu == 0 || parentMenu->size.y != 1 ) clearEvent(e); break; default: target = this; ch = getAltChar(e.keyDown.keyCode); if( ch == 0 ) ch = e.keyDown.charScan.charCode; else target = topMenu(); p = target->findItem(ch); if( p == 0 ) { p = topMenu()->hotKey(e.keyDown.keyCode); if( p != 0 && commandEnabled(p->command) ) { result = p->command; action = doReturn; } } else if( target == this ) { if( size.y == 1 ) autoSelect = True; action = doSelect; current = p; } else if( parentMenu != target || parentMenu->current != p ) action = doReturn; } break; case evCommand: if( e.message.command == cmMenu ) { autoSelect = False; if (parentMenu != 0 ) action = doReturn; } else action = doReturn; break; } if( itemShown != current ) { itemShown = current; drawView(); } if( (action == doSelect || (action == doNothing && autoSelect)) && current != 0 && current->name != 0 ) if( current->command == 0 ) { if( (e.what & (evMouseDown | evMouseMove)) != 0 ) putEvent(e); r = getItemRect( current ); r.a.x = r.a.x + origin.x; r.a.y = r.b.y + origin.y; r.b = owner->size; if( size.y == 1 ) r.a.x--; target = topMenu()->newSubView(r, current->subMenu,this); result = owner->execView(target); destroy( target ); } else if( action == doSelect ) result = current->command; if( result != 0 && commandEnabled(result) ) { action = doReturn; clearEvent(e); } } while( action != doReturn ); if( e.what != evNothing && (parentMenu != 0 || e.what == evCommand)) putEvent(e); if( current != 0 ) { menu->deflt = current; current = 0; drawView(); } return result; }