本文整理汇总了C++中setCursorPos函数的典型用法代码示例。如果您正苦于以下问题:C++ setCursorPos函数的具体用法?C++ setCursorPos怎么用?C++ setCursorPos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCursorPos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeCharacter
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;
}
示例2: handle
// Pressed left button
long TextLabel::onLeftBtnPress(FXObject*,FXSelector,void* ptr)
{
FXEvent* ev=(FXEvent*)ptr;
handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
if (isEnabled())
{
grab();
if (target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr))
return 1;
flags&=~FLAG_UPDATE;
if (ev->click_count==1)
{
setCursorPos(index(ev->win_x));
if (ev->state&SHIFTMASK)
extendSelection(cursor);
else
{
killSelection();
setAnchorPos(cursor);
}
makePositionVisible(cursor);
flags|=FLAG_PRESSED;
}
else
{
setAnchorPos(0);
setCursorPos(contents.length());
extendSelection(contents.length());
makePositionVisible(cursor);
}
return 1;
}
return 0;
}
示例3: consoleEnd
void consoleEnd() {
setCursorPos(0);
if (completionEnd>cmdEnd)
setCursorPos(completionEnd);
else
setCursorPos(cmdEnd);
drawerInvokeRedisplay();
}
示例4: handled
bool TextInputWidget::handleKey(int key) {
bool handled(true);
if (!_hasFocus) return false;
std::wstring old_input(_input);
int size = static_cast<int>(_input.size());
switch (key) {
case osgGA::GUIEventAdapter::KEY_Left:
setCursorPos(_cursorPos - 1);
break;
case osgGA::GUIEventAdapter::KEY_Right:
setCursorPos(_cursorPos + 1);
break;
case osgGA::GUIEventAdapter::KEY_BackSpace:
if ((_cursorPos >= size) && (size >=1))
{
// letztes Zeichen löschen
_input = _input.substr(0, size - 2);
setCursorPos(getCursorPosition()-1);
}
else if ((_cursorPos >= 0) && (_cursorPos < size))
{
//Zeichen links vom Cursor löschen
_input = _input.substr(0,_cursorPos)+_input.substr(_cursorPos+1, size);
setCursorPos(getCursorPosition()-1);
}
break;
case osgGA::GUIEventAdapter::KEY_Delete:
case osgGA::GUIEventAdapter::KEY_KP_Delete:
if ((_cursorPos > 0) && (_cursorPos < size-1))
_input = _input.substr(0,_cursorPos+1)+_input.substr(_cursorPos+2, size);
break;
default:
if (key >= 0xff00) {
handled = false;
} else {
// std::cout <<"key " << key << std::endl;
// TODO hande utf?
if (_cursorPos < size)
_input.insert(_cursorPos+1, 1, static_cast<char>(key));
else
_input += static_cast<char>(key);
_cursorPos++;
}
}
if (_input != old_input)
informAttachedResponder(Actions::valueChanged());
if (handled)
update();
return handled;
}
示例5: consoleRight
void consoleRight() {
if ((cursorPos+cursorLen<cmdEnd) || (cursorPos+cursorLen<completionEnd)) {
if (cursorPos+cursorLen==cmdEnd)
setCursorPos(cursorPos+2);
else
setCursorPos(cursorPos+1);
}
drawerInvokeRedisplay();
}
示例6: consoleLeft
void consoleLeft() {
if (cursorPos>cmdBegin) {
if (cursorPos==cmdEnd+1)
setCursorPos(cursorPos-2);
else
setCursorPos(cursorPos-1);
}
drawerInvokeRedisplay();
}
示例7: removeCharacter
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;
}
示例8: applyCompletion
void applyCompletion() {
if (cursorPos>cmdEnd) {
int pos=cursorPos;
setCursorPos(0);
consoleLines->str[pos]='\0';
utilStrRmChars(consoleLines->str+cmdEnd, 1);
cmdEnd=pos-1;
setCursorPos(cmdEnd);
} else {
consoleLines->str[cmdEnd]='\0';
}
completionEnd=0;
}
示例9: setCursorPos
// Clears the entire screen
bool Console::clearScreen(void)
{
cout.flush();
setCursorPos(0, 0);
DWORD numCharactersWritten;
COORD consoleCoords = {0, 0};
GetConsoleScreenBufferInfo(consoleHandle, &consoleInfo);
FillConsoleOutputCharacter(consoleHandle, ' ', consoleInfo.dwSize.X * consoleInfo.dwSize.Y, consoleCoords, &numCharactersWritten);
FillConsoleOutputAttribute(consoleHandle, consoleInfo.wAttributes, consoleInfo.dwSize.X * consoleInfo.dwSize.Y, consoleCoords, &numCharactersWritten);
setCursorPos(0, 0);
cout.flush();
return true;
}
示例10: setCursorPos
void TextEdit::onMouseDragged(const SimGui::Event &event)
{
int pos = setCursorPos(event.ptMouse);
//if the position is to the left
if (pos == -1)
{
scrollDir = -1;
}
//else if the position is to the right
else if (pos == -2)
{
scrollDir = 1;
}
//else set the new cursor position
else
{
scrollDir = 0;
cursorPos = pos;
}
//update the block
blockStart = min(cursorPos, mouseDragStart);
blockEnd = max(cursorPos, mouseDragStart);
if (blockStart < 0) blockStart = 0;
if (blockStart == blockEnd)
{
blockStart = blockEnd = 0;
}
//let the parent get the event
Parent::onMouseDragged(event);
}
示例11: QWidget
QHexEditPrivate::QHexEditPrivate(QScrollArea *parent) : QWidget(parent)
{
_undoStack = new QUndoStack(this);
_scrollArea = parent;
_asciiArea = true;
setOverwriteMode(true);
setCursorPos(0);
setAddressArea(true);
setAddressWidth(4);
setAddressOffset(0);
setAsciiArea(true);
setHighlighting(true);
setReadOnly(false);
setAddressAreaColor(QColor(0xd4, 0xd4, 0xd4, 0xff));
setHighlightingColor(QColor(0xff, 0xff, 0x99, 0xff));
setSelectionColor(QColor(0x6d, 0x9e, 0xff, 0xff));
setFont(QFont("Courier", 10));
_size = 0;
resetSelection(0);
setFocusPolicy(Qt::StrongFocus);
connect(&_cursorTimer, SIGNAL(timeout()), this, SLOT(updateCursor()));
_cursorTimer.setInterval(500);
_cursorTimer.start();
}
示例12: consoleKeyPress
void consoleKeyPress(char c) {
if (!cursorPos)
openConsole("");
applyCompletion();
int pos=cursorPos;
setCursorPos(0);
cmdLineRealloc(1);
utilStrInsertChar(consoleLines->str+pos, c);
cmdEnd++;
updateCompletions();
setCursorPos(pos+1);
drawerInvokeRedisplay();
}
示例13: drawReminder
void drawReminder()
{
fb_setClipping(3,41,252, 150);
fb_drawRect(0,37,255,148,textAreaFillColor);
setFont(font_arial_9);
setColor(textAreaTextColor);
setWrapToBorder();
if(blinkOn())
{
if(isInsert())
setCursorProperties(cursorNormalColor, 1, -1, 0);
else
setCursorProperties(cursorOverwriteColor, 1, -1, 0);
showCursor();
setCursorPos(getKBCursor());
}
setFakeHighlight();
fb_dispString(0,-3,reminder);
setWrapNormal();
hideCursor();
clearHighlight();
drawCurDay();
}
示例14: line1
void SciDoc::removeLine() {
// LOGGER;
JuffScintilla* edit = int_->curEdit_;
if ( edit == NULL ) return;
int line1(-1), line2(-1), col1(-1), col2(-1);
if ( edit->hasSelectedText() ) {
edit->getSelection(&line1, &col1, &line2, &col2);
if ( col2 == 0 )
--line2;
if (line1 <= line2 && line1 >= 0) {
setCursorPos(line1, 0);
edit->beginUndoAction();
for (int l = line1; l <= line2; ++l) {
edit->SendScintilla(QsciScintilla::SCI_LINEDELETE);
}
edit->endUndoAction();
}
}
else {
edit->getCursorPosition(&line1, &col1);
if ( line1 >= 0 ) {
edit->SendScintilla(QsciScintilla::SCI_LINEDELETE);
}
}
}
示例15: defined
bool BaseApp::onMouseMove(const int x, const int y, const int deltaX, const int deltaY){
if (mouseCaptured){
#if defined(__APPLE__)
wx -= (invertMouse? 1 : -1) * mouseSensibility * deltaY;
wy -= mouseSensibility * deltaX;
#else
static bool changed = false;
if (changed = !changed){
wx += (invertMouse? 1 : -1) * mouseSensibility * (height / 2 - y);
wy += mouseSensibility * (width / 2 - x);
setCursorPos(width / 2, height / 2);
}
#endif
return true;
} else {
if (widgets.goToFirst()){
do {
Widget *widget = widgets.getCurrent();
if (widget->isEnabled() && widget->isVisible() && (widget->isInWidget(x, y) || widget->isCapturing())){
//widgets.moveCurrentToTop();
return widget->onMouseMove(x, y);
}
} while (widgets.goToNext());
}
}
return false;
}