本文整理汇总了C++中gcn::KeyEvent类的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent类的具体用法?C++ KeyEvent怎么用?C++ KeyEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
void PlayControllerZone::keyPressed( gcn::KeyEvent& keyEvent )
{
switch ( keyEvent.getKey().getValue() )
{
case gcn::Key::LEFT:
view().Scroll( 1,
IMap::WEST );
break;
case gcn::Key::RIGHT:
view().Scroll( 1,
IMap::EAST );
break;
case gcn::Key::UP:
view().Scroll( 1,
IMap::NORTH );
break;
case gcn::Key::DOWN:
view().Scroll( 1,
IMap::SOUTH );
break;
default:
;
}
keyEvent.consume();
}
示例2: keyPressed
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent)
{
if (keyEvent.isConsumed() || !isFocused())
return;
if (keyEvent.getKey().getValue() == Key::LEFT)
{
int index = getSelectedTabIndex();
index--;
if (index < 0)
setSelectedTab(mTabs[mTabs.size() - 1].first);
else
setSelectedTab(mTabs[index].first);
keyEvent.consume();
}
else if (keyEvent.getKey().getValue() == Key::RIGHT)
{
int index = getSelectedTabIndex();
index++;
if (index >= (int) mTabs.size())
setSelectedTab(mTabs[0].first);
else
setSelectedTab(mTabs[index].first);
keyEvent.consume();
}
}
示例3: keyPressed
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent)
{
if (keyEvent.isConsumed() || !isFocused())
return;
if (keyEvent.getKey().getValue() == Key::LEFT)
{
TabContainer::iterator index = getTabIterator(mSelectedTab);
if (index != mTabs.begin())
setSelectedTab((--index)->first);
else
setSelectedTab((--mTabs.end())->first);
keyEvent.consume();
}
else if (keyEvent.getKey().getValue() == Key::RIGHT)
{
TabContainer::iterator index = getTabIterator(mSelectedTab);
if (index != (--mTabs.end()))
setSelectedTab((++index)->first);
else
setSelectedTab(mTabs.begin()->first);
keyEvent.consume();
}
}
示例4: keyPressed
// -- KeyListener notifications
void ListBox::keyPressed(gcn::KeyEvent& keyEvent)
{
gcn::Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
{
if (keyEvent.isShiftPressed())
{
const std::string actionEventId = getActionEventId();
setActionEventId("default");
distributeActionEvent();
setActionEventId(actionEventId);
}
else
distributeActionEvent();
}
else if (key.getValue() == Key::UP)
decrementSelected();
else if (key.getValue() == Key::DOWN)
incrementSelected();
else if (key.getValue() == Key::HOME)
setSelected(0);
else if (key.getValue() == Key::END)
setSelected(getListModel()->getNumberOfElements() - 1);
else
return;
keyEvent.consume();
}
示例5: keyPressed
void ChatInput::keyPressed(gcn::KeyEvent &event)
{
TextField::keyPressed(event);
if (event.getKey().getValue() == Key::DOWN && mCurHist != mHistory.end())
{
// Move forward through the history
HistoryIterator prevHist = mCurHist++;
if (mCurHist != mHistory.end())
{
setText(*mCurHist);
setCaretPosition(getText().length());
}
else
mCurHist = prevHist;
}
else if (event.getKey().getValue() == Key::UP && mCurHist !=
mHistory.begin() && mHistory.size() > 0)
{
// Move backward through the history
mCurHist--;
setText(*mCurHist);
setCaretPosition(getText().length());
}
}
示例6: keyPressed
void Slider::keyPressed(gcn::KeyEvent &keyEvent)
{
gcn::Key key = keyEvent.getKey();
if (getOrientation() == HORIZONTAL)
{
if (key.getValue() == Key::RIGHT)
{
setValue(getValue() + getStepLength());
distributeActionEvent();
keyEvent.consume();
}
else if (key.getValue() == Key::LEFT)
{
setValue(getValue() - getStepLength());
distributeActionEvent();
keyEvent.consume();
}
}
else
{
if (key.getValue() == Key::UP)
{
setValue(getValue() + getStepLength());
distributeActionEvent();
keyEvent.consume();
}
else if (key.getValue() == Key::DOWN)
{
setValue(getValue() - getStepLength());
distributeActionEvent();
keyEvent.consume();
}
}
}
示例7: keyPressed
void IntTextField::keyPressed(gcn::KeyEvent &event)
{
int action = static_cast<KeyEvent*>(&event)->getActionId();
if (action == Input::KEY_GUI_DELETE || action == Input::KEY_GUI_BACKSPACE)
{
setText(std::string());
if (mSendAlwaysEvents)
distributeActionEvent();
event.consume();
}
if (!event.getKey().isNumber())
return;
TextField::keyPressed(event);
std::istringstream s(getText());
int i;
s >> i;
setValue(i);
if (mSendAlwaysEvents)
distributeActionEvent();
}
示例8: keyReleased
void GlassWidget::keyReleased(gcn::KeyEvent &e) {
if(me) {
PyObject *res = PyObject_CallMethod(me, "_keyReleased", "(ii)", e.getType(), e.getKey().getValue());
if(res == NULL && PyErr_Occurred() != NULL)
Py_HandleError();
else
Py_XDECREF(res);
}
}
示例9: keyPressed
void IntroController::keyPressed( gcn::KeyEvent& keyEvent )
{
if ( keyEvent.getKey().getValue() == gcn::Key::ESCAPE ) {
model().final(); //! Paramos el bucle asi?.......
keyEvent.consume();
}
示例10:
void DBSH07TextField::keyPressed(gcn::KeyEvent &keyEvent)
{
if (keyEvent.getKey().getValue() != ',')
{
if (getText().size() < 10 || keyEvent.getKey().getValue() == gcn::Key::BACKSPACE || keyEvent.getKey().getValue() == gcn::Key::ENTER)
{
gcn::TextField::keyPressed(keyEvent);
}
}
}
示例11: keyPressed
void FileDialog::keyPressed(gcn::KeyEvent& ke)
{
if(ke.getKey() == gcn::Key::ESCAPE)
{
Close();
}
else if(ke.getKey() == gcn::Key::ENTER)
{
_HandleSelection();
}
}
示例12: keyPressed
void ChatBox::keyPressed(gcn::KeyEvent& keyEvent){
//if( keyEvent.isConsumed() ){ return; }
//if enter pressed
if( keyEvent.getKey().getValue() == gcn::Key::ENTER ){
// on the input field
if ( keyEvent.getSource() == inputField ){
// add the text from the text field into the chat area
push_back( inputField->getText(), DO_CALLBACK|PUT_USERNAME );
//clear off the text field
inputField->setText("");
}
}
}
示例13: keyPressed
void Menu::keyPressed(gcn::KeyEvent& keyEvent) {
std::cout << "Menu::keyPressed" << std::endl;
hikari::Input::Button button =
InputHelper::getMappedButtonForKey(keyEvent.getKey());
if(button == Input::BUTTON_UP) {
selectPreviousItem();
keyEvent.consume();
} else if(button == Input::BUTTON_DOWN) {
selectNextItem();
keyEvent.consume();
} else if(button == Input::BUTTON_START || button == Input::BUTTON_SHOOT) {
distributeActionEvent();
}
}
示例14: keyPressed
void FFScrollArea::keyPressed(gcn::KeyEvent &keyEvent)
{
if (keyEvent.isConsumed())
{
return;
}
if (keyEvent.getKey().getValue() == gcn::Key::Down)
{
setVerticalScrollAmount(getVerticalScrollAmount() + 16);
}
else if (keyEvent.getKey().getValue() == gcn::Key::Up)
{
setVerticalScrollAmount(getVerticalScrollAmount() - 16);
}
}
示例15: keyPressed
void keyPressed(gcn::KeyEvent& keyEvent)
{
bool bHandled = false;
Uint8 *keystate;
gcn::Key key = keyEvent.getKey();
if (key.getValue() == gcn::Key::UP)
{
keystate = SDL_GetKeyState(NULL);
if(keystate[SDLK_RSHIFT])
{
int selected = listBox->getSelected() - 10;
if(selected < 0)
selected = 0;
listBox->setSelected(selected);
bHandled = true;
}
}
if (key.getValue() == gcn::Key::DOWN)
{
keystate = SDL_GetKeyState(NULL);
if(keystate[SDLK_RSHIFT])
{
int selected = listBox->getSelected() + 10;
if(selected >= dirList.getNumberOfElements())
selected = dirList.getNumberOfElements() - 1;
listBox->setSelected(selected);
bHandled = true;
}
}
if(!bHandled)
listBox->keyPressed(keyEvent);
}