/// Bind a mouse action to the python io map /// @param action a string version of the action to bind to the map /// @param pyAction the python action to take when the state is correct void PyIOMap::BindMouseAction( const std::string& action, PythonIOMapping::Action pyAction ) { // convert the strings into values InputCode inputCode = GetInputCode( ParseTokens(action, "+" ) ); IOMapping::InputType eInputType = GetInputType( IOMapping::kInputSource_Mouse, action ); // bind the button BindIO( IOMapping::kInputSource_Mouse, eInputType, inputCode, pyAction ); }
/// Bind a key to the python io map /// @param key a string version of the key to bind to the map /// @param inputType a string version of the input type to bind /// @param pyAction the python action to take when the state is correct void PyIOMap::BindKey( const std::string& key, const std::string& inputType, PythonIOMapping::Action pyAction ) { // convert the parameters into values InputCode inputCode = GetInputCode( ParseTokens( key, "+" ) ); IOMapping::InputType eInputType = GetInputType( IOMapping::kInputSource_Keyboard, inputType); // bind the key BindIO( IOMapping::kInputSource_Keyboard, eInputType, inputCode, pyAction ); }
bool CGM_Slider::HandleKeyboardInput( CGM_InputData& input ) { if( !IsEnabled() || !IsVisible() ) return false; switch( GetInputCode(input) ) { case CGM_Input::INCREASE_SLIDER_VALUE: if( input.type == CGM_InputData::TYPE_PRESSED ) { SetValueInternal( m_iValue + m_iShiftAmount, true ); return true; } break; case CGM_Input::DECREASE_SLIDER_VALUE: if( input.type == CGM_InputData::TYPE_PRESSED ) { SetValueInternal( m_iValue - m_iShiftAmount, true ); return true; } break; } /* SPoint pt = input.pos; if( input.code == m_aInputCode[ IC_INCREASE ] ) { if( input.type == CGM_InputData::TYPE_PRESSED ) { SetValueInternal( m_iValue + m_iShiftAmount, true ); return true; } } else if( input.code == m_aInputCode[ IC_DECREASE ] ) { if( input.type == CGM_InputData::TYPE_PRESSED ) { SetValueInternal( m_iValue - m_iShiftAmount, true ); return true; } } */ return false; }
bool CGM_Slider::HandleMouseInput( CGM_InputData& input ) { if( !IsEnabled() || !IsVisible() ) return false; SPoint pt = input.pos; // switch( input.code ) switch( GetInputCode(input) ) { case CGM_Input::MOUSE_BUTTON_L: if( input.type == CGM_InputData::TYPE_PRESSED ) { if( m_ButtonRect.ContainsPoint( pt ) ) { // Pressed while inside the control m_bPressed = true; // SetCapture( DXUTGetHWND() ); m_iDragX = pt.x; // m_iDragY = pt.y; m_iDragOffset = m_iButtonX - m_iDragX; // m_nDragValue = m_nValue; if( !HasFocus() ) m_pDialog->RequestFocus( this ); return true; } if( m_BoundingBox.ContainsPoint( pt ) ) { // pressed inside the slider control if( m_iButtonX + m_BoundingBox.left < pt.x ) { SetValueInternal( m_iValue + 1, true ); return true; } if( pt.x < m_BoundingBox.left + m_iButtonX ) { SetValueInternal( m_iValue - 1, true ); return true; } } break; } else if( input.type == CGM_InputData::TYPE_RELEASED ) { if( IsPressed() ) { m_bPressed = false; // ReleaseCapture(); // m_pDialog->ClearFocus(); m_pDialog->SendEvent( CGM_Event::SLIDER_VALUE_CHANGED, true, this ); return true; } } break; case CGM_Input::MOUSE_AXIS_X: case CGM_Input::MOUSE_AXIS_Y: if( IsPressed() ) { SetValueInternal( ValueFromPos( m_BoundingBox.left + pt.x + m_iDragOffset ), true ); return true; } break; default: break; } return false; }