本文整理汇总了C++中gcn::MouseEvent类的典型用法代码示例。如果您正苦于以下问题:C++ MouseEvent类的具体用法?C++ MouseEvent怎么用?C++ MouseEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MouseEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseDragged
void Viewport::mouseDragged(gcn::MouseEvent &event)
{
if (!mCurrentMap || !player_node)
return;
if (mPlayerFollowMouse && mWalkTime == player_node->mWalkTime)
{
const int tileWidth = mCurrentMap->getTileWidth();
const int tileHeight = mCurrentMap->getTileHeight();
int destX = event.getX() / tileWidth + mTileViewX;
int destY = event.getY() / tileHeight + mTileViewY;
player_node->setDestination(destX, destY);
}
}
示例2: mouseMoved
// Show ItemTooltip
void ItemContainer::mouseMoved(gcn::MouseEvent &event)
{
Item *item = mInventory->getItem(getSlotIndex(event.getX(), event.getY()));
if (item)
{
mItemPopup->setItem(item->getInfo());
mItemPopup->view(viewport->getMouseX(), viewport->getMouseY());
}
else
{
mItemPopup->setVisible(false);
}
}
示例3: mouseReleased
void GlassWindow::mouseReleased(gcn::MouseEvent& mouseEvent) {
if(titleVisible) {
if(mouseEvent.getY() <= (int)mTitleBarHeight && mouseEvent.getX()>=titleBarContainer.getX()) {
gcn::Button *w;
if((w = (gcn::Button*)titleBarContainer.getWidgetAt(mouseEvent.getX()-titleBarContainer.getX(), mouseEvent.getY())) != NULL) {
w->mouseReleased(mouseEvent);
}
}
}
gcn::Window::mouseReleased(mouseEvent);
GlassWidget::mouseReleased(mouseEvent);
}
示例4: mousePressed
void ItemContainer::mousePressed(gcn::MouseEvent &event)
{
if (!mInventory)
return;
const int button = event.getButton();
mClicks = event.getClickCount();
if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT)
{
const int index = getSlotIndex(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
return;
Item *item = mInventory->getItem(index);
// put item name into chat window
if (item && mDescItems && chatWindow)
chatWindow->addItemText(item->getInfo().getName());
if (mSelectedIndex == index && mClicks != 2)
{
mSelectionStatus = SEL_DESELECTING;
}
else if (item && item->getId())
{
setSelectedIndex(index);
mSelectionStatus = SEL_SELECTING;
int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < SHORTCUT_TABS)
{
if (itemShortcut[num])
itemShortcut[num]->setItemSelected(item);
}
if (dropShortcut)
dropShortcut->setItemSelected(item);
if (item->isEquipment() && outfitWindow)
outfitWindow->setItemSelected(item);
if (shopWindow)
shopWindow->setItemSelected(item->getId());
}
else
{
selectNone();
}
}
}
示例5: mouseClicked
void PlayState::mouseClicked( gcn::MouseEvent& mouseEvent )
{
if (mouseEvent.GetSource() == mQuitButton)
{
Close();
}
}
示例6: mouseMoved
void ShopListBox::mouseMoved(gcn::MouseEvent &event)
{
if (!mShopItems)
return;
int index = event.getY() / mRowHeight;
if (index < 0 || index >= mShopItems->getNumberOfElements())
{
mItemPopup->setVisible(false);
}
else
{
Item *item = mShopItems->at(index);
if (item)
{
mItemPopup->setItem(item->getInfo());
mItemPopup->position(viewport->getMouseX(), viewport->getMouseY());
}
else
{
mItemPopup->setVisible(false);
}
}
}
示例7: mouseClicked
void ItemMakerBox::mouseClicked(gcn::MouseEvent& mouseEvent){
if( mouseEvent.isConsumed() ){ return; };
// Save Button
if( mouseEvent.getSource() == saveBtn ){
mouseEvent.consume();
save( filenameFld->getText() );
} else
// Load Button
if( mouseEvent.getSource() == loadBtn ){
mouseEvent.consume();
load( filenameFld->getText() );
} else {
setCaption(caption_);
}
}
示例8: mouseDragged
void Viewport::mouseDragged(gcn::MouseEvent &event)
{
if (!mMap || !player_node)
return;
if (mPlayerFollowMouse && !event.isShiftPressed())
{
if (get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay)
{
mLocalWalkTime = tick_time;
player_node->setDestination(event.getX() + (int) mPixelViewX,
event.getY() + (int) mPixelViewY);
player_node->pathSetByMouse();
}
}
}
示例9: mousePressed
// -- MouseListener notifications
void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
{
if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
{
int row = getRowForY(mouseEvent.getY());
int column = getColumnForX(mouseEvent.getX());
if (row > -1 && column > -1 &&
row < mModel->getRows() && column < mModel->getColumns())
{
mSelectedColumn = column;
mSelectedRow = row;
}
distributeActionEvent();
}
}
示例10: mouseMoved
// Show ItemTooltip
void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
{
if (event.getSource() == mItemIcon)
{
mItemPopup->setItem(mItem->getInfo());
mItemPopup->position(viewport->getMouseX(), viewport->getMouseY());
}
}
示例11: mouseMoved
// Show ItemTooltip
void ItemContainer::mouseMoved(gcn::MouseEvent &event)
{
if (!mInventory)
return;
Item *item = mInventory->getItem(getSlotIndex(event.getX(), event.getY()));
if (item && viewport)
{
mItemPopup->setItem(item);
mItemPopup->position(viewport->getMouseX(), viewport->getMouseY());
}
else
{
mItemPopup->setVisible(false);
}
}
示例12: mousePressed
void OutfitWindow::mousePressed(gcn::MouseEvent &event)
{
Window::mousePressed(event);
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1) {
return;
}
// Stores the selected item if there is one.
if (isItemSelected()) {
mItems[mCurrentOutfit][index] = mItemSelected;
mItemSelected = -1;
}
else if (mItems[mCurrentOutfit][index]) {
mItemClicked = true;
}
}
示例13: mouseWheelMovedDown
void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
if (isFocused())
{
incrementSelected();
mouseEvent.consume();
}
}
示例14: mouseMoved
void Viewport::mouseMoved(gcn::MouseEvent &event)
{
// Check if we are on the map
if (!mMap || !player_node)
return;
const int x = (event.getX() + (int) mPixelViewX);
const int y = (event.getY() + (int) mPixelViewY);
mHoverBeing = actorSpriteManager->findBeingByPixel(x, y);
mBeingPopup->show(getMouseX(), getMouseY(), mHoverBeing);
mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
y / mMap->getTileHeight());
updateCursorType();
}
示例15: mouseClicked
void BuyDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
{
if (mouseEvent.getSource() == mShopItemList &&
isDoubleClick(mShopItemList->getSelected()))
{
action(gcn::ActionEvent(mBuyButton, mBuyButton->getActionEventId()));
}
}