bool UILineEdit::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifiers) { if(keyCode == Fw::KeyDelete) // erase right character removeCharacter(true); else if(keyCode == Fw::KeyBackspace) // erase left character { removeCharacter(false); else if(keyCode == Fw::KeyRight) // move cursor right moveCursor(true); else if(keyCode == Fw::KeyLeft) // move cursor left moveCursor(false); else if(keyCode == Fw::KeyHome) // move cursor to first character setCursorPos(0); else if(keyCode == Fw::KeyEnd) // move cursor to last character setCursorPos(m_text.length()); else if(keyCode == Fw::KeyV && keyboardModifiers == Fw::KeyboardCtrlModifier) appendText(g_window.getClipboardText()); else if(keyCode == Fw::KeyTab) { if(!m_alwaysActive) { if(UIWidgetPtr parent = getParent()) parent->focusNextChild(Fw::TabFocusReason); } } else if(!keyText.empty() && (keyboardModifiers == Fw::KeyboardNoModifier || keyboardModifiers == Fw::KeyboardShiftModifier)) appendText(keyText); else return false; return true; }
bool UITextEdit::onKeyPress(uchar keyCode, int keyboardModifiers, int autoRepeatTicks) { if(UIWidget::onKeyPress(keyCode, keyboardModifiers, autoRepeatTicks)) return true; if(keyboardModifiers == Fw::KeyboardNoModifier) { if(keyCode == Fw::KeyDelete) { // erase right character removeCharacter(true); return true; } else if(keyCode == Fw::KeyBackspace) { // erase left character { removeCharacter(false); return true; } else if(keyCode == Fw::KeyRight && !m_shiftNavigation) { // move cursor right moveCursor(true); return true; } else if(keyCode == Fw::KeyLeft && !m_shiftNavigation) { // move cursor left moveCursor(false); return true; } else if(keyCode == Fw::KeyHome) { // move cursor to first character setCursorPos(0); return true; } else if(keyCode == Fw::KeyEnd) { // move cursor to last character setCursorPos(m_text.length()); return true; } else if(keyCode == Fw::KeyTab && !m_shiftNavigation) { if(UIWidgetPtr parent = getParent()) parent->focusNextChild(Fw::KeyboardFocusReason); return true; } else if(keyCode == Fw::KeyEnter && m_multiline) { appendCharacter('\n'); return true; } else if(keyCode == Fw::KeyUp && !m_shiftNavigation && m_multiline) { } else if(keyCode == Fw::KeyDown && !m_shiftNavigation && m_multiline) { } } else if(keyboardModifiers == Fw::KeyboardCtrlModifier) { if(keyCode == Fw::KeyV) { appendText(g_window.getClipboardText()); return true; } } else if(keyboardModifiers == Fw::KeyboardShiftModifier) { if(keyCode == Fw::KeyRight && m_shiftNavigation) { // move cursor right moveCursor(true); return true; } else if(keyCode == Fw::KeyLeft && m_shiftNavigation) { // move cursor left moveCursor(false); return true; } } return false; }
void UrlBar::handleKeyReleaseEvent(const XKeyReleasedEvent& event) { char normalKey; KeySym specialKey; XLookupString(const_cast<XKeyEvent*>(&event), &normalKey, sizeof(char), &specialKey, 0); switch (specialKey) { case XK_BackSpace: removeCharacter(); break; case XK_Delete: deleteCharacter(); break; case XK_Home: m_cursorPosition = 0; break; case XK_End: m_cursorPosition = m_url.length(); break; case XK_Left: if (m_cursorPosition) m_cursorPosition--; break; case XK_Right: if (m_cursorPosition < m_url.length()) m_cursorPosition++; break; case XK_Return: loadPage(); break; case XK_Insert: if (event.state & ControlMask) becomeClipboardOwner(); else if (event.state & ShiftMask) requestClipboardText(); break; default: if (event.state & ControlMask) { // while the Control key is pressed, character codes start from 1 (A=1, B=2, ...). switch (normalKey + 'A' - 1) { case 'C': becomeClipboardOwner(); break; case 'V': requestClipboardText(); break; } } else appendCharacter(normalKey); break; } drawUrlBar(); }
void PhysicEngine::addCharacter(std::string name) { // Remove character with given name, so we don't make memory // leak when character would be added twice removeCharacter(name); PhysicActor* newActor = new PhysicActor(name); dynamicsWorld->addCollisionObject( newActor->externalGhostObject, COL_ACTOR_EXTERNAL, COL_WORLD |COL_ACTOR_EXTERNAL ); dynamicsWorld->addCollisionObject( newActor->internalGhostObject, COL_ACTOR_INTERNAL, COL_WORLD |COL_ACTOR_INTERNAL ); dynamicsWorld->addAction( newActor->mCharacter ); PhysicActorMap[name] = newActor; }
void UITextEdit::del(bool right) { if(hasSelection()) { std::string tmp = m_text; tmp.erase(m_selectionStart, m_selectionEnd - m_selectionStart); setCursorPos(m_selectionStart); clearSelection(); setText(tmp); } else removeCharacter(right); }
void PhysicEngine::addCharacter(std::string name, std::string mesh, Ogre::Vector3 position, float scale, Ogre::Quaternion rotation) { // Remove character with given name, so we don't make memory // leak when character would be added twice removeCharacter(name); PhysicActor* newActor = new PhysicActor(name, mesh, this, position, rotation, scale); //dynamicsWorld->addAction( newActor->mCharacter ); PhysicActorMap[name] = newActor; }
void QCustomTableWidget::onVHeaderClicked(int index, const QPoint &position) { QAction *action = vMenu->exec(position); if (action == actionVAdd) { addCharacter(index); } else if (action == actionVRemove) { removeCharacter(index); } else if (action == actionVEdit) { editCharacter(index); } }
CharTableView::CharTableView(QWidget * parent) : QTableView(parent), zoom(nullptr) { deleteAct = new QAction( tr("Delete"), this); connect(deleteAct, SIGNAL(triggered()), this, SLOT(removeCharacter())); connect(this, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(viewDoubleClicked(const QModelIndex &))); actionMenu = new QMenu(this); actionMenu->addAction(deleteAct); setAcceptDrops(false); setDropIndicatorShown(true); verticalHeader()->setVisible(false); horizontalHeader()->setVisible(false); }
void QCustomTableWidget::onVHeaderClicked(int index, const QPoint &position) { bool null = (index != -1); actionRemoveRow->setVisible(null); actionEditRow->setVisible(null); QAction *action = vMenu->exec(position); if (action == actionAddRow) { addCharacter(index); } else if (action == actionRemoveRow) { removeCharacter(index); } else if (action == actionEditRow) { editCharacter(index); } }
void QCustomTableWidget::mousePressEvent(QMouseEvent *e) { int rowPosition, columnPosition; QTableWidgetItem *qtwitem = itemAt(e->pos()); switch (e->button()) { case Qt::LeftButton: { if (qtwitem && !qtwitem->isSelected()) { QTableWidget::mousePressEvent(e); } else { setCurrentItem(0); } break; } case Qt::RightButton: { if (qtwitem) { setCurrentItem(qtwitem); rowPosition = visualRow(currentRow()); columnPosition = visualColumn(currentColumn()); } else { rowPosition = rowCount()-1; columnPosition = columnCount()-1; } QTableWidget::mousePressEvent(e); bool null = (qtwitem != 0); actionRemoveColumn->setVisible(null); actionEditColumn->setVisible(null); actionRemoveRow->setVisible(null); actionEditRow->setVisible(null); QAction* action = menu->exec(e->globalPos()); if (action == actionAddColumn) { addProperty(columnPosition); } else if (action == actionRemoveColumn) { if (qtwitem) { removeProperty(columnPosition); } } else if (action == actionEditColumn) { if (qtwitem) { editProperty(columnPosition); } } else if (action == actionAddRow) { addCharacter(rowPosition); } else if (action == actionRemoveRow) { if (qtwitem) { removeCharacter(rowPosition); } } else if (action == actionEditRow) { if (qtwitem) { editCharacter(rowPosition); } } break; } default: break; } }
void QCustomTableWidget::keyReleaseEvent(QKeyEvent *e) { QTableWidgetItem *item = currentItem(); int row = visualRow(currentRow()); int column = visualColumn(currentColumn()); Qt::KeyboardModifiers modifs = e->modifiers(); switch (e->key()) { case Qt::Key_F2: if (!bEditing) { if (modifs == Qt::ControlModifier) { editProperty(column); } else if (modifs == (Qt::ControlModifier | Qt::ShiftModifier)) { editCharacter(row); } else if (item) { bEditing = true; editItem(item); } } break; case Qt::Key_Delete: if (!bEditing) { if (modifs == Qt::ControlModifier) { removeProperty(column); } else if (modifs == (Qt::ControlModifier | Qt::ShiftModifier)) { removeCharacter(row); } else if (item) { item->setText("0"); } } break; case Qt::Key_Insert: if (!bEditing) { if (modifs == Qt::ControlModifier) { addProperty(column); } else if (modifs == (Qt::ControlModifier | Qt::ShiftModifier)) { addCharacter(row); } else { QTableWidget::keyReleaseEvent(e); } } break; case Qt::Key_Return: case Qt::Key_Enter: case Qt::Key_Escape: bEditing = false; break; default: QTableWidget::keyReleaseEvent(e); break; } }
void WorldPage::insertCharacter(const CharacterPtr& ch) { removeCharacter(ch); m_players.push_back(ch); };
void StringTools::trimStringKeepingAllBlanks (std::string& string) { removeCharacter(string,'\r'); removeCharacter(string,'\n'); removeCharacter(string,'\t'); }