当前位置: 首页>>代码示例>>C++>>正文


C++ setFocus函数代码示例

本文整理汇总了C++中setFocus函数的典型用法代码示例。如果您正苦于以下问题:C++ setFocus函数的具体用法?C++ setFocus怎么用?C++ setFocus使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setFocus函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setFocus

void eTimeCorrectionEditWindow::yearChanged( eListBoxEntryText* )
{
	cmonth->setCurrent( (int) cmonth->getCurrent()->getKey(), true );
	setFocus(cyear);
}
开发者ID:ChakaZulu,项目名称:tuxbox_apps,代码行数:5,代码来源:time_correction.cpp

示例2: setFocus

/*!

*/
void ColorPickerButton::mouseMoveEvent(QMouseEvent *)
{
    setFocus();
    update();
}
开发者ID:DocX,项目名称:action-bomberman,代码行数:8,代码来源:qtcolorpicker.cpp

示例3: setFocusPolicy

void DkControlWidget::init() {

	// debug: show invisible widgets
	setFocusPolicy(Qt::StrongFocus);
	setFocus(Qt::TabFocusReason);
	setMouseTracking(true);

	// connect widgets with their settings
	mFilePreview->setDisplaySettings(&Settings::param().app().showFilePreview);
	mMetaDataInfo->setDisplaySettings(&Settings::param().app().showMetaData);
	mFileInfoLabel->setDisplaySettings(&Settings::param().app().showFileInfoLabel);
	mPlayer->setDisplaySettings(&Settings::param().app().showPlayer);
	mHistogram->setDisplaySettings(&Settings::param().app().showHistogram);
	mCommentWidget->setDisplaySettings(&Settings::param().app().showComment);
	mZoomWidget->setDisplaySettings(&Settings::param().app().showOverview);
	mFolderScroll->setDisplaySettings(&Settings::param().app().showScroller);

	// some adjustments
	mBottomLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	mBottomLeftLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	mRatingLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	mZoomWidget->setContentsMargins(10, 10, 0, 0);
	mCropWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
	mCommentWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

	// register actions
	DkActionManager& am = DkActionManager::instance();
	mFilePreview->registerAction(am.action(DkActionManager::menu_panel_preview));
	mMetaDataInfo->registerAction(am.action(DkActionManager::menu_panel_exif));
	mPlayer->registerAction(am.action(DkActionManager::menu_panel_player));
	mCropWidget->registerAction(am.action(DkActionManager::menu_edit_crop));
	mFileInfoLabel->registerAction(am.action(DkActionManager::menu_panel_info));
	mHistogram->registerAction(am.action(DkActionManager::menu_panel_histogram));
	mCommentWidget->registerAction(am.action(DkActionManager::menu_panel_comment));
	mFolderScroll->registerAction(am.action(DkActionManager::menu_panel_scroller));

	// dummy - needed for three equal columns @markus: do not delete!
	QWidget* dw = new QWidget(this);
	dw->setMouseTracking(true);
	QBoxLayout* dLayout = new QBoxLayout(QBoxLayout::LeftToRight, dw);
	dLayout->setContentsMargins(0,0,0,0);
	dLayout->addWidget(mBottomLabel);
	dLayout->addStretch();

	// zoom widget
	QWidget* bw = new QWidget(this);
	bw->setMouseTracking(true);
	//bw->setMinimumHeight(40);
	//bw->setMaximumHeight(80);
	QVBoxLayout* zLayout = new QVBoxLayout(bw);
	zLayout->setAlignment(Qt::AlignBottom);
	zLayout->setContentsMargins(0,0,0,20);
	zLayout->setSpacing(0);
	zLayout->addWidget(mBottomLabel);
	zLayout->addWidget(mBottomLeftLabel);
	zLayout->addWidget(mCommentWidget);

	// left column widget
	QWidget* leftWidget = new QWidget(this);
	leftWidget->setMouseTracking(true);
	QBoxLayout* ulLayout = new QBoxLayout(QBoxLayout::TopToBottom, leftWidget);
	ulLayout->setContentsMargins(0,0,0,0);
	ulLayout->setSpacing(0);
	ulLayout->addWidget(mZoomWidget);
	ulLayout->addStretch();
	ulLayout->addWidget(bw);
	ulLayout->addWidget(dw);

	// center column
	QWidget* center = new QWidget(this);
	center->setMouseTracking(true);
	QVBoxLayout* cLayout = new QVBoxLayout(center);
	cLayout->setContentsMargins(0,0,0,0);
	cLayout->setAlignment(Qt::AlignBottom);
	cLayout->addWidget(mPlayer);
	
	// rating widget
	QWidget* rw = new QWidget(this);
	rw->setMouseTracking(true);
	rw->setMinimumSize(0,0);
	QBoxLayout* rLayout = new QBoxLayout(QBoxLayout::RightToLeft, rw);
	rLayout->setContentsMargins(0,0,0,17);
	rLayout->addWidget(mRatingLabel);
	rLayout->addStretch();

	// file info
	QWidget* fw = new QWidget(this);
	fw->setContentsMargins(0,0,0,30);
	fw->setMouseTracking(true);
	fw->setMinimumSize(0,0);
	QBoxLayout* rwLayout = new QBoxLayout(QBoxLayout::RightToLeft, fw);
	rwLayout->setContentsMargins(0,0,0,0);
	rwLayout->addWidget(mFileInfoLabel);
	rwLayout->addStretch();

	// right column
	QWidget* hw = new QWidget(this);
	hw->setContentsMargins(0,10,10,0);
	hw->setMouseTracking(true);
	QBoxLayout* hwLayout = new QBoxLayout(QBoxLayout::RightToLeft, hw);
//.........这里部分代码省略.........
开发者ID:nholmgaard,项目名称:nomacs,代码行数:101,代码来源:DkControlWidget.cpp

示例4: Q_D

/*! \reimp  */
bool QGroupBox::event(QEvent *e)
{
    Q_D(QGroupBox);
#ifndef QT_NO_SHORTCUT
    if (e->type() == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (se->shortcutId() == d->shortcutId) {
            if (!isCheckable()) {
                d->_q_fixFocus(Qt::ShortcutFocusReason);
            } else {
                d->click();
                setFocus(Qt::ShortcutFocusReason);
            }
            return true;
        }
    }
#endif
    QStyleOptionGroupBox box;
    initStyleOption(&box);
    switch (e->type()) {
    case QEvent::HoverEnter:
    case QEvent::HoverMove: {
        QStyle::SubControl control = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box,
                                                                    static_cast<QHoverEvent *>(e)->pos(),
                                                                    this);
        bool oldHover = d->hover;
        d->hover = d->checkable && (control == QStyle::SC_GroupBoxLabel || control == QStyle::SC_GroupBoxCheckBox);
        if (oldHover != d->hover) {
            QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)
                         | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this);
            update(rect);
        }
        return true;
    }
    case QEvent::HoverLeave:
        d->hover = false;
        if (d->checkable) {
            QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)
                         | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this);
            update(rect);
        }
        return true;
    case QEvent::KeyPress: {
        QKeyEvent *k = static_cast<QKeyEvent*>(e);
        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
            d->pressedControl = QStyle::SC_GroupBoxCheckBox;
            update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
            return true;
        }
        break;
    }
    case QEvent::KeyRelease: {
        QKeyEvent *k = static_cast<QKeyEvent*>(e);
        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
            bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
                           || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
            d->pressedControl = QStyle::SC_None;
            if (toggle)
                d->click();
            return true;
        }
        break;
    }
    default:
        break;
    }
    return QWidget::event(e);
}
开发者ID:cdaffara,项目名称:symbiandump-mw3,代码行数:69,代码来源:qgroupbox.cpp

示例5: setChecked

/*! \internal

    Makes sure the button isn't pressed when the popup hides.
*/
void QtColorPicker::popupClosed()
{
    setChecked(false);
    setFocus();
}
开发者ID:DocX,项目名称:action-bomberman,代码行数:9,代码来源:qtcolorpicker.cpp

示例6: setFocus

void AquariaMenuItem::destroy()
{
	setFocus(false);
	Quad::destroy();
	AquariaGuiElement::clean();
}
开发者ID:4nakin,项目名称:Aquaria_clean,代码行数:6,代码来源:AquariaMenuItem.cpp

示例7: setFocus

void Console::mousePressEvent(QMouseEvent*)
{
    setFocus();
}
开发者ID:who-is-here,项目名称:FreeCiscoSimulator,代码行数:4,代码来源:console.cpp

示例8: setFocus

void RazorAppSwitcher::SwitcherItem::mouseMoveEvent(QMouseEvent * e)
{
    if (! hasFocus())
        setFocus(Qt::MouseFocusReason);
}
开发者ID:tq,项目名称:razor-qt,代码行数:5,代码来源:appswitcher.cpp

示例9: QAction

void NMainMenuBar::setupEditMenu() {
    editMenu = this->addMenu(tr("&Edit"));
    QFont f = global.getGuiFont(QFont());
    editMenu->setFont(f);

    undoAction = new QAction(tr("&Undo"), this);
    setupShortcut(undoAction, QString("Edit_Undo"));
    editMenu->addAction(undoAction);

    redoAction = new QAction(tr("&Redo"), this);
    setupShortcut(redoAction, QString("Edit_Redo"));
    editMenu->addAction(redoAction);

    editMenu->addSeparator();

    cutAction = new QAction(tr("&Cut"), this);
    setupShortcut(cutAction, QString("Edit_Cut"));
    editMenu->addAction(cutAction);

    copyAction = new QAction(tr("C&opy"), this);
    setupShortcut(copyAction, QString("Edit_Copy"));
    editMenu->addAction(copyAction);

    pasteAction = new QAction(tr("&Paste"), this);
    setupShortcut(pasteAction, QString("Edit_Paste"));
    editMenu->addAction(pasteAction);

    pasteAsTextAction = new QAction(tr("Pas&te as Unformatted Text"), this);
    setupShortcut(pasteAsTextAction, QString("Edit_Paste_Without_Formatting"));
    editMenu->addAction(pasteAsTextAction);

    removeFormattingAction = new QAction(tr("Remo&ve Formatting"), this);
    //setupShortcut(removeFormjattingAction, QString("Edit_Remove_Formatting")); // For some reason this one makes the editorButtonBar one ambiguous
    editMenu->addAction(removeFormattingAction);

    editMenu->addSeparator();

    selectAllAction = new QAction(tr("Select &All"), this);
    setupShortcut(selectAllAction, QString("Edit_Select_All"));
    editMenu->addAction(selectAllAction);

    editMenu->addSeparator();

    findReplaceMenu = editMenu->addMenu(tr("F&ind and Replace"));
    findReplaceMenu->setFont(f);

    searchNotesAction = new QAction(tr("&Search Notes"), this);
    setupShortcut(searchNotesAction, QString("Edit_Search_Notes"));
    findReplaceMenu->addAction(searchNotesAction);
    connect(searchNotesAction, SIGNAL(triggered()), parent->searchText, SLOT(setFocus()));

    resetSearchAction = new QAction(tr("&Reset Search"), this);
    setupShortcut(resetSearchAction, QString("Edit_Reset_Search"));
    findReplaceMenu->addAction(resetSearchAction);
    connect(resetSearchAction, SIGNAL(triggered()), parent, SLOT(resetView()));

    findReplaceMenu->addSeparator();

    searchFindAction = new QAction(tr("&Find in Note"), this);
    setupShortcut(searchFindAction, QString("Edit_Search_Find"));
    findReplaceMenu->addAction(searchFindAction);
    connect(searchFindAction, SIGNAL(triggered()), parent, SLOT(findInNote()));


    searchFindNextAction = new QAction(tr("Find &Next"), this);
    setupShortcut(searchFindNextAction, QString("Edit_Search_Find_Next"));
    findReplaceMenu->addAction(searchFindNextAction);
    connect(searchFindNextAction, SIGNAL(triggered()), parent, SLOT(findNextInNote()));

    searchFindPrevAction = new QAction(tr("Find &Previous"), this);
    setupShortcut(searchFindPrevAction, QString("Edit_Search_Find_Prev"));
    findReplaceMenu->addAction(searchFindPrevAction);
    connect(searchFindPrevAction, SIGNAL(triggered()), parent, SLOT(findPrevInNote()));

    findReplaceMenu->addSeparator();

    searchFindReplaceAction = new QAction(tr("Replace &Within Note..."), this);
    setupShortcut(searchFindReplaceAction, QString("Edit_Search_Find_Replace"));
    findReplaceMenu->addAction(searchFindReplaceAction);
    connect(searchFindReplaceAction, SIGNAL(triggered()), parent, SLOT(findReplaceInNote()));

    editMenu->addSeparator();

    createThemeMenu(editMenu);

    preferencesAction = new QAction(tr("Preferences"), this);
    preferencesAction->setMenuRole(QAction::PreferencesRole);
    setupShortcut(preferencesAction, QString("Edit_Preferences"));
    editMenu->addAction(preferencesAction);
    connect(preferencesAction, SIGNAL(triggered()), parent, SLOT(openPreferences()));

}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:92,代码来源:nmainmenubar.cpp

示例10: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    readSettings();
    ui->actionSound->setChecked(settings.soundsenabled);

    irc = new QIrc();
    if (!irc->createSession())
    {
        QMessageBox::critical(this, tr("Error"), tr("Can't create session"));
        close();
        return;
    }
    connect(irc, SIGNAL(sigConnected()), this, SLOT(sltConnected()));
    connect(irc, SIGNAL(sigMessage(QString,QString)), this, SLOT(sltMessage(QString,QString)));
    connect(irc, SIGNAL(sigChannelJoined(QString,QString)), this, SLOT(sltChannelJoined(QString,QString)));
    connect(irc, SIGNAL(sigChannelParted(QString,QString,QString)), this, SLOT(sltChannelParted(QString,QString,QString)));
    connect(irc, SIGNAL(sigChannelNames(QString,QString,QStringList)), this, SLOT(sltChannelNames(QString,QString,QStringList)));
    connect(irc, SIGNAL(sigChannelMessage(QString,QString,QString)), this, SLOT(sltChannelMessage(QString,QString,QString)));
    connect(irc, SIGNAL(sigPrivateMessage(QString,QString,QString)), this, SLOT(sltPrivateMessage(QString,QString,QString)));
    connect(irc, SIGNAL(sigNick(QString,QString)), this, SLOT(sltNick(QString,QString)));
    connect(irc, SIGNAL(sigNotice(QString,QString,QString)), this, SLOT(sltNotice(QString,QString,QString)));
    connect(irc, SIGNAL(sigTopic(QString,QString,QString)), this, SLOT(sltTopic(QString,QString,QString)));
    connect(irc, SIGNAL(sigTopicSet(QString,QString,QString,QString)), this, SLOT(sltTopicSet(QString,QString,QString,QString)));
    connect(irc, SIGNAL(sigKick(QString,QString,QString)), this, SLOT(sltKick(QString,QString,QString)));
    connect(irc, SIGNAL(sigQuit(QString,QString)), this, SLOT(sltQuit(QString,QString)));
    connect(irc, SIGNAL(sigChannelModeChanged(QString,QString,QStringList)), this, SLOT(sltChannelModeChanged(QString,QString,QStringList)));
    connect(irc, SIGNAL(sigUmode(QString,QString)), this, SLOT(sltUmode(QString,QString)));
    connect(irc, SIGNAL(sigInvite(QString,QString,QString)), this, SLOT(sltInvite(QString,QString,QString)));
    connect(irc, SIGNAL(sigCtcpAction(QString,QString,QString)), this, SLOT(sltCtcpAction(QString,QString,QString)));
    connect(irc, SIGNAL(sigErrorOccured(QString)), this, SLOT(sltErrorOccured(QString)));

    consolebrowser = new QTextEdit();
    consolebrowser->setReadOnly(true);
    QFont consolefont;
    if (consolefont.fromString(settings.consolefont))
        consolebrowser->setFont(consolefont);

    if (!settings.hideconsole)
        consoleindex =ui->tabWidget->insertTab(0, consolebrowser, tr("Console"));

    setsdlg = 0;

    usercontextmenu = new QMenu(this);
    usercontextmenu->addAction(ui->actionPrivateChat);
    usercontextmenu->addAction(ui->actionInsert_to_editor);
    QMenu *managementmenu = usercontextmenu->addMenu(tr("Management"));
    managementmenu->addAction(ui->actionKick);
    managementmenu->addAction(ui->actionBan);
    managementmenu->addAction(ui->actionKickBan);
    managementmenu->addSeparator();
    managementmenu->addAction(ui->actionOp);
    managementmenu->addAction(ui->actionDeOp);
    managementmenu->addSeparator();
    managementmenu->addAction(ui->actionVoice);
    managementmenu->addAction(ui->actiondeVoice);
    connect(ui->treeWidget, SIGNAL(userContextMenu(QPoint)), this, SLOT(userContextMenuRequested(QPoint)));

    channelcontextmenu = new QMenu(this);
    channelcontextmenu->addAction(ui->actionLeave_channel);
    channelcontextmenu->addAction(ui->actionChannel_settings);
    connect(ui->treeWidget, SIGNAL(channelContextMenu(QPoint)), this, SLOT(channelContextMenuRequested(QPoint)));

    channelsettingsdialog = 0;
    trayicon = 0;
    traymenu = 0;
    setTrayIcon(settings.trayicon);
    connect(ui->actionChannel_settings, SIGNAL(triggered()), this, SLOT(channelSettingsPressed()));

    //smile menu
    smilemenu = new QMenu(this);
    smilewidgetaction = new QWidgetAction(smilemenu);
    smilebar = new SmileBar();
    smilewidgetaction->setDefaultWidget(smilebar);
    smilemenu->addAction(smilewidgetaction);
    connect(smilebar, SIGNAL(smileClicked(QString)), ui->plainTextEditMessage, SLOT(insertPlainText(QString)));
    connect(smilebar, SIGNAL(smileClicked(QString)), ui->plainTextEditMessage, SLOT(setFocus()));
    ui->actionEmoticons->setMenu(smilemenu);
    smilebutton = new QToolButton();
    smilebutton->setDefaultAction(ui->actionEmoticons);
    smilebutton->setPopupMode(QToolButton::InstantPopup);
    ui->mainToolBar->addWidget(smilebutton);

    channellistdialog = new ChannelListDialog();
    connect(irc, SIGNAL(sigChannelListStart()), channellistdialog, SLOT(showAndClear()));
    connect(irc, SIGNAL(sigChannelListAddItem(QString,QString,QString)), channellistdialog,
            SLOT(addListItem(QString,QString,QString)));
    connect(irc, SIGNAL(sigChannelListEnd()), channellistdialog, SLOT(endOfList()));
    connect(channellistdialog, SIGNAL(channelDoubleClicked(QString)), irc, SLOT(joinChannel(QString)));

    connect(ui->pushButtonSend, SIGNAL(clicked()), ui->plainTextEditMessage, SIGNAL(sendKeyPressed()));
    connect(ui->plainTextEditMessage, SIGNAL(sendKeyPressed()), this, SLOT(sendPressed()));
    connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(connectPressed()));
    connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(disconnectPressed()));
    connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(settingsPressed()));
    connect(ui->actionJoin, SIGNAL(triggered()), this, SLOT(joinPressed()));
    connect(ui->treeWidget, SIGNAL(userDoubleClicked(QString)), this, SLOT(userDoubleClicked(QString)));
    connect(ui->actionPrivateChat, SIGNAL(triggered()), this, SLOT(privateChatPressed()));
//.........这里部分代码省略.........
开发者ID:reddrop,项目名称:datawolf3-moarstuffandgoats,代码行数:101,代码来源:mainwindow.cpp

示例11: fkey

void TERMWINDOWMEMBER fkey(uint inkey)
    {
    int key = inkey >> 8;

    // this handles the keys for dialout mode
    if (DoWhat == DIALOUT)
        {
        dialout_fkey = key;
        return;
        }

    // let RLM take over keyboard if it wants
    if (!CitadelIsConfiguring && rlmEvent(LT_KEYSTROKE, key, inkey))
        {
        return;
        }

    if (cfg.FullConLock && ConsoleLock.IsLocked() && ScreenSaver.IsOn() &&
            key != ALT_L)
        {
        return;
        }

    if (!LockMessages(MSG_CONSOLE))
        {
        cOutOfMemory(49);
        }

    if (key == CTL_F2)      // CTRL_F2 is never locked.
        {
#ifndef WINCIT
        if (allWindows)
            {
            setFocus(allWindows->wnd);
            }
#endif
        }
    else if (key != ALT_F1 && ConsoleLock.IsLocked(key == F6 || key == ALT_F6 || key == SFT_F6 || key == CTL_F6))
        {
#ifndef WINCIT
        if (key == ALT_L && ConsoleLock.MayUnlock())
            {
            GetStringFromConsole(getmsg(MSG_CONSOLE, 0), LABELSIZE, ns, GetSysPWHandler, TRUE);
            }
        else
            {
            if (cfg.VerboseConsole)
                {
                CitWindowsNote(NULL, (key == ALT_L) ? getmsg(MSG_CONSOLE, 1) : getmsg(MSG_CONSOLE, 2));
                }
            }
#endif
        }
    else
        {
        // Console is not locked

        if (CitadelIsConfiguring)
            {
            // Only let certain keystrokes through if configuring
            if (key != CTL_F6 && key != F7 && key != F8 && key != ALT_D && key != ALT_L && key != ALT_M &&
                    key != ALT_S && key != ALT_U)
                {
                WaitUntilDoneConfiguring();
                key = 0;
                }
            }

        ScreenSaver.Update();
        switch (key)
            {
            case F1:
                {
                CITWINDOW *w = CitWindowsMsg(NULL, getmsg(MSG_CONSOLE, 3));

#ifndef WINCIT
                CommPort->DropDtr();
#endif

                if (w)
                    {
                    destroyCitWindow(w, FALSE);
                    }

                break;
                }

#ifndef WINCIT
            case CTL_F1:
                {
                if (say_ascii != (int (cdecl *)(const char *, int)) nullFunc)
                    {
                    cfg.speechOn = !cfg.speechOn;

                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 4), cfg.speechOn ? getmsg(317) : getmsg(316));
                        }
                    }
                else
//.........这里部分代码省略.........
开发者ID:dylancarlson,项目名称:citplus,代码行数:101,代码来源:conovl.cpp

示例12: switch

//! posts an input event to the environment
bool Ui::handleEvent( const NEvent& event )
{  
  switch(event.EventType)
  {
    case sEventGui:
      // hey, why is the user sending gui events..?
    break;

    case sEventMouse:
        _d->cursorPos = event.mouse.pos();

//!!! android fix. update hovered element on every mouse event,
//!   that beforeDraw() function cannot do it correctly
#ifdef CAESARIA_PLATFORM_ANDROID
        _updateHovered( _d->cursorPos );
#endif
//!!! end android fix
        switch( event.mouse.type )
        {
        case mouseLbtnPressed:
        case mouseRbtnPressed:
        {
            if ( (_d->hovered.current.isValid() && _d->hovered.current != getFocus()) || !getFocus() )
            {
              setFocus( _d->hovered.current.object() );
            }

            // sending input to focus
            Widget* inFocus = getFocus();
            if( inFocus )
            {
              bool eventResolved = getFocus()->onEvent(event);
              if( eventResolved )
              {
                return true;
              }
            }

            // focus could have died in last call
            inFocus = getFocus();
            if( !inFocus && _d->hovered.current.isValid() )
            {                
              return _d->hovered.current->onEvent(event);
            }
        }
        break;

        case mouseLbtnRelease:
          if( getFocus() )
          {
            return getFocus()->onEvent( event );
          }
        break;

        default:
          if( _d->hovered.current.isValid() )
          {
            return _d->hovered.current->onEvent( event );
          }
        break;
        }
    break;

    case sTextInput:
    case sEventKeyboard:
        {
          if( _d->console )
          {
            if(  _d->console->initKey() == (int)event.keyboard.symbol )
            {
              if( _d->console && !event.keyboard.control && event.keyboard.pressed )
                  _d->console->toggleVisible();

              return true;
            }

            if( _d->console->visible() && !event.keyboard.control && event.keyboard.pressed )
            {
              _d->console->keyPress( event );
              return true;
            }
          }

          if( getFocus() && getFocus()->onEvent(event))
            return true;

          // For keys we handle the event before changing focus to give elements the chance for catching the TAB
          // Send focus changing event
          if( event.EventType == sEventKeyboard &&
              event.keyboard.pressed &&
              event.keyboard.key == KEY_TAB)
          {
            Widget *wdg = next(event.keyboard.shift, event.keyboard.control);
            if (wdg && wdg != getFocus())
            {
                if( setFocus(wdg) )
                    return true;
            }
          }
//.........这里部分代码省略.........
开发者ID:binakot,项目名称:caesaria-game,代码行数:101,代码来源:environment.cpp

示例13: setFocus

//------------------------------------------------------------------------------
// The user has 'finished editing' such as pressed return/enter or moved
// focus from the object.
// Note, it doesn't matter if the user presses return and both this function
// AND userReturnPressed() is called since setText is called in each to clear
// the 'isModified' flag. So, the first called will perform the write, the
// second (if any) will do nothing.
//
void QEGenericEdit::userEditingFinished()
{
    // If not connected, do nothing
    if( !isConnected )
    {
        return;
    }

    // Do nothing if the user is still effectivly working with the widget (just moved to a dialog box)
    // Any signals received while messageDialogPresent is true should be ignored.
    // A signal occurs after the 'write failed' dialog closes, so a it sets
    // writeFailMessageDialogPresent to allow this code to ignore the signal.
    if( messageDialogPresent || writeFailMessageDialogPresent )
    {
        if( !messageDialogPresent )
        {
            writeFailMessageDialogPresent = false;
            setFocus();
        }
        return;
    }

    // If no changes were made by the user, do nothing
    if( !isModified() || !writeOnFinish )
    {
        return;
    }

    // Get the variable to write to
    qcaobject::QCaObject *qca = getQcaItem(0);

    // If a QCa object is present (if there is a variable to write to)
    // and the object is set up to write when the user changes focus away from the object
    // and the text has actually changed
    // then write the value
    if( qca && writeOnLoseFocus )
    {
       // Note: getValue is a dispatching hook procedure.
       writeValue( qca, getValue () );
    }

    // If, for what ever reason, the value has been changed by the user but not but not written
    // check with the user what to do about it.
    else
    {
        messageDialogPresent = true;
        int confirm = QMessageBox::warning( this, "Value changed", "You altered a value but didn't write it.\nDo you want to write this value?",
                                            QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::No );
        messageDialogPresent = false;

        switch( confirm )
        {
            // Write the value
            case QMessageBox::Yes:
                if( qca ) {
                   // Note: getValue is a dispatching hook procedure.
                   writeValue( qca, getValue () );
                }
                break;

            // Abort the write, revert to latest value
            case QMessageBox::No:
                setValue( lastValue );       // Note, also clears 'isModified' flag
                                             // setValue  is dispatching hook function
                break;

            // Don't write the value, move back to the field being edited
            case QMessageBox::Cancel:
                setFocus();
                break;
        }
    }
}
开发者ID:rorydog1,项目名称:epics,代码行数:81,代码来源:QEGenericEdit.cpp

示例14: ptf

void QFormulatorEditWidget::mousePressEvent( QMouseEvent *e )
{
	if( e->button() == Qt::LeftButton )
	{
		PointFde ptf( e->x(), e->y() );
		RectFde rcf = clientRect();
		CFmlDrawEngineQt::DPtoLPEx( ptf, scale(), scale() );
		CFmlDrawEngineQt::DPtoLPEx( rcf, scale(), scale() );

		if( rootNode()->PtInSelection( rcf, ptf ) == 0 )
		{
			editCopy(); // to enable interoperating with Other Applications

			CFrameNode *pFrameNode = rootNode()->RemoveOrCopySelection( 0 );
			if( pFrameNode )
			{
				CRootNode *pRootNode = new CRootNode( this );
				// zero marginds when inserting from a server
				pRootNode->setIndents( 0, 0, 0, 0 );
				pRootNode->Insert( pFrameNode );
				QPixmap pixmap;
				if( ::isOption_Perfomance_CopyImage() )
					pixmap = drawSelection2QPixmap( true );
				QImage pixImg = pixmap.toImage();
				QMimeData *mimeData = CFormulatorDoc::copyToMimeData( pRootNode, pixmap.isNull() ? 0 : &pixImg );
				if( mimeData )
				{
					QDrag *drag = new QDrag( this );
					drag->setMimeData( mimeData );
					if( !pixmap.isNull() )
					{
						const int dragPixmapMaxSize = 256;
						if( qMax(pixmap.width(), pixmap.height()) > dragPixmapMaxSize )
							drag->setPixmap( pixmap.width() > pixmap.height() ? pixmap.scaledToWidth( dragPixmapMaxSize ) : pixmap.scaledToHeight( dragPixmapMaxSize ) );
						else
							drag->setPixmap( pixmap );
					}
					drag->setHotSpot( QPoint(0, 0) );

					clearRemovedSelection();
					Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction);
					if( dropAction == Qt::MoveAction && isRemovedSelection() == 0 )
					{
						CFrameNode *pRemovedFrame = rootNode()->RemoveOrCopySelection( 1 );
						if( pRemovedFrame )
						{
							delete pRemovedFrame;
							setRemovedSelection();
						}
						if( !hasFocus() ) setFocus();
						updateViewDocument();
					}
				}

				delete pRootNode;
				delete pFrameNode;
			}
		}
		else if( rootNode()->MoveCaret( rcf, ptf, e->modifiers() & Qt::ShiftModifier ) == 0 )
		{
			updateFormulatorWidget();
		}

		//cbFireEvent( FORMULIB_CALLBACK_LMOUSECLICK, nFlags, MAKEWPARAM( point.x(), point.y() ) );
	}
	else if( e->button() == Qt::RightButton )
	{
		//cbFireEvent( FORMULIB_CALLBACK_RMOUSECLICK, nFlags, MAKEWPARAM( point.x(), point.y() ) );
	}
}
开发者ID:Nilis640,项目名称:formulator-mathml,代码行数:70,代码来源:fmleditwidget.cpp

示例15: switch

// virtual
void LLPanelLandmarkInfo::setInfoType(EInfoType type)
{
	LLPanel* landmark_info_panel = getChild<LLPanel>("landmark_info_panel");

	bool is_info_type_create_landmark = type == CREATE_LANDMARK;

	landmark_info_panel->setVisible(type == LANDMARK);

	getChild<LLTextBox>("folder_label")->setVisible(is_info_type_create_landmark);
	mFolderCombo->setVisible(is_info_type_create_landmark);

	switch(type)
	{
		case CREATE_LANDMARK:
		{
			mCurrentTitle = getString("title_create_landmark");

			mLandmarkTitle->setVisible(FALSE);
			mLandmarkTitleEditor->setVisible(TRUE);
			mNotesEditor->setEnabled(TRUE);

			LLViewerParcelMgr* parcel_mgr = LLViewerParcelMgr::getInstance();
			std::string name = parcel_mgr->getAgentParcelName();
			LLVector3 agent_pos = gAgent.getPositionAgent();

			if (name.empty())
			{
				S32 region_x = llround(agent_pos.mV[VX]);
				S32 region_y = llround(agent_pos.mV[VY]);
				S32 region_z = llround(agent_pos.mV[VZ]);

				std::string region_name;
				LLViewerRegion* region = parcel_mgr->getSelectionRegion();
				if (region)
				{
					region_name = region->getName();
				}
				else
				{
					region_name = getString("unknown");
				}

				mLandmarkTitleEditor->setText(llformat("%s (%d, %d, %d)",
									  region_name.c_str(), region_x, region_y, region_z));
			}
			else
			{
				mLandmarkTitleEditor->setText(name);
			}

			std::string desc;
			LLAgentUI::buildLocationString(desc, LLAgentUI::LOCATION_FORMAT_FULL, agent_pos);
			mNotesEditor->setText(desc);

			// Moved landmark creation here from LLPanelLandmarkInfo::processParcelInfo()
			// because we use only agent's current coordinates instead of waiting for
			// remote parcel request to complete.
			if (!LLLandmarkActions::landmarkAlreadyExists())
			{
				createLandmark(LLUUID());
			}
		}
		break;

		case LANDMARK:
		default:
			mCurrentTitle = getString("title_landmark");

			mLandmarkTitle->setVisible(TRUE);
			mLandmarkTitleEditor->setVisible(FALSE);
			mNotesEditor->setEnabled(FALSE);
		break;
	}

	populateFoldersList();

	// Prevent the floater from losing focus (if the sidepanel is undocked).
	setFocus(TRUE);

	LLPanelPlaceInfo::setInfoType(type);
}
开发者ID:OS-Development,项目名称:VW.Kirsten,代码行数:82,代码来源:llpanellandmarkinfo.cpp


注:本文中的setFocus函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。