Exemplo n.º 1
0
void FormWidget::HandleKey( int key_code )
{
    if ( Widget **p = _accelerators.Find(key_code) )
    {
        if ( (*p)->IsRealyVisible() )
        {
            (*p)->Accept( Widget::InputAccel(key_code) );
        }
    }

    if ( key_code == _submit_key )
    {
        OnSubmit.Switch( true );
    }
    else if ( key_code == _cancel_key )
    {
        OnSubmit.Switch( false );
    }

    else if ( key_code == Keys::TAB )
    {
        bool backwards = IsKeyPressed( Keys::LSHIFT ) || IsKeyPressed( Keys::RSHIFT );
        bool context = IsKeyPressed( Keys::LCTRL ) || IsKeyPressed( Keys::RCTRL );
        Form *pform = (context)? &GetEnvironment()->GetForm() : this;
        assert( pform );
        pform->CycleFocus( (backwards)? PREVIOUS : NEXT );
    }
    else if ( key_code==Keys::UP || key_code==Keys::LEFT )
    {
        CycleFocus( PREVIOUS );
    }
    else if ( key_code == Keys::DOWN || key_code==Keys::RIGHT )
    {
        CycleFocus( NEXT );
    }
}
Exemplo n.º 2
0
//-- Tell parent form to focus other widget
//-- Method releases focus
void FormWidget::CycleParentForm( int mode )
{
    Form *pform = &GetEnvironment()->GetForm();
    pform->CycleFocus( mode );
}