本文整理汇总了C++中gcn::MouseEvent::getButton方法的典型用法代码示例。如果您正苦于以下问题:C++ MouseEvent::getButton方法的具体用法?C++ MouseEvent::getButton怎么用?C++ MouseEvent::getButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcn::MouseEvent
的用法示例。
在下文中一共展示了MouseEvent::getButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mousePressed
void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
return;
if (event.getButton() == gcn::MouseEvent::LEFT)
{
// Stores the selected item if theirs one.
if (itemShortcut->isItemSelected() && inventoryWindow->isVisible())
{
itemShortcut->setItem(index);
itemShortcut->setItemSelected(-1);
}
else if (itemShortcut->getItem(index))
mItemClicked = true;
}
else if (event.getButton() == gcn::MouseEvent::RIGHT)
{
Item *item = player_node->getInventory()->
findItem(itemShortcut->getItem(index));
if (!item)
return;
// Convert relative to the window coordinates to absolute screen
// coordinates.
viewport->showPopup(viewport->getMouseX(), viewport->getMouseY(), item);
}
}
示例2: mousePressed
void WorldEditor::mousePressed(gcn::MouseEvent& mouseEvent)
{
if (mouseEvent.getSource() != this)
{
return;
}
if (mDrawingNewRoom)
{
mDrawingNewRoom = false;
return;
}
if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
{
if (mWorldPieces.find(mRoomSelector->getSelectedRoom()) == mWorldPieces.end())
{
WorldPiece* worldPiece = new WorldPiece(mRoomSelector->getSelectedRoom());
mWorldPieces[mRoomSelector->getSelectedRoom()] = worldPiece;
worldPiece->setPosition(mouseEvent.getX() - mouseEvent.getX() % 20,
mouseEvent.getY() - mouseEvent.getY() % 15);
worldPiece->addActionListener(this);
add(worldPiece);
}
}
else if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
{
if (!mNewRoomDialogWindow->isVisible()
&& getWidgetAt(mouseEvent.getX(), mouseEvent.getY()) == NULL)
{
mDrawingNewRoom = true;
if (mouseEvent.getX() % 20 < 10)
{
mNewRoomX = mouseEvent.getX() - mouseEvent.getX() % 20;
}
else
{
mNewRoomX = mouseEvent.getX() - mouseEvent.getX() % 20 + 20;
}
if (mouseEvent.getY() % 15 < 8)
{
mNewRoomY = mouseEvent.getY() - mouseEvent.getY() % 15;
}
else
{
mNewRoomY = mouseEvent.getY() - mouseEvent.getY() % 15 + 15;
}
mNewRoomWidth = 0;
mNewRoomHeight = 0;
}
}
}
示例3: mousePressed
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
{
Window::mousePressed(mouseEvent);
if (!mEquipment)
return;
const int x = mouseEvent.getX();
const int y = mouseEvent.getY();
if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
{
if (mForing)
return;
// Checks if any of the presses were in the equip boxes.
int i = 0;
for (std::vector<EquipmentBox*>::const_iterator it = mBoxes.begin(),
it_end = mBoxes.end(); it != it_end; ++ it, ++ i)
{
EquipmentBox *box = *it;
if (!box)
continue;
Item *item = mEquipment->getEquipment(i);
const gcn::Rectangle tRect(box->x, box->y,
BOX_WIDTH, BOX_HEIGHT);
if (tRect.isPointInRect(x, y) && item)
setSelected(i);
}
}
else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
{
if (Item *item = getItem(x, y))
{
if (mItemPopup)
mItemPopup->setVisible(false);
/* Convert relative to the window coordinates to absolute screen
* coordinates.
*/
const int mx = x + getX();
const int my = y + getY();
if (viewport)
{
if (mForing)
viewport->showUndressPopup(mx, my, mBeing, item);
else
viewport->showPopup(this, mx, my, item, true);
}
}
}
}
示例4: setSelected
/*
void GuildListBox::setSelected(int selected)
{
if (!mListModel)
{
mSelected = -1;
}
else
{
// Update mSelected with bounds checking
mSelected = std::min(mListModel->getNumberOfElements() - 1,
std::max(-1, selected));
gcn::Widget *parent;
parent = (gcn::Widget*)getParent();
if (parent)
{
gcn::Rectangle scroll;
scroll.y = (mSelected < 0) ? 0 : getFont()->getHeight() * mSelected;
scroll.height = getFont()->getHeight();
parent->showWidgetPart(this, scroll);
}
}
distributeValueChangedEvent();
}
*/
void GuildListBox::mousePressed(gcn::MouseEvent &event)
{
if (event.getButton() == gcn::MouseEvent::LEFT)
{
int y = event.getY();
setSelected(y / getFont()->getHeight());
distributeActionEvent();
}
// TODO: Add guild functions, ie private messaging
if (event.getButton() == gcn::MouseEvent::RIGHT)
{
// Show context menu
}
}
示例5: mousePressed
void Windowiki::mousePressed(gcn::MouseEvent &event)
{
// Let Guichan move window to top and figure out title bar drag
gcn::Window::mousePressed(event);
const int x = event.getX();
const int y = event.getY();
mMouseResize = 0;
// Activate resizing handles as appropriate
if (event.getSource() == this && isResizable() &&
event.getButton() == gcn::MouseEvent::LEFT &&
!getChildrenArea().isPointInRect(x, y))
{
mMouseResize |= (x > getWidth() - resizeBorderWidthiki) ? RIGHT :
(x < resizeBorderWidthiki) ? LEFT : 0;
mMouseResize |= (y > getHeight() - resizeBorderWidthiki) ? BOTTOM :
(y < resizeBorderWidthiki) ? TOP : 0;
}
else if (event.getSource() == mGrip)
{
mDragOffsetX = x + mGrip->getX();
mDragOffsetY = y + mGrip->getY();
mMouseResize |= BOTTOM | RIGHT;
mIsMoving = false;
}
if (event.getButton() == gcn::MouseEvent::LEFT)
{
const int x = event.getX();
const int y = event.getY();
// Handle close button
if (mCloseButton)
{
gcn::Rectangle closeButtonRect(
getWidth() - closeImage->getWidth() - getPadding(),
getPadding(),
closeImage->getWidth(),
closeImage->getHeight());
if (closeButtonRect.isPointInRect(x, y))
{
setVisible(false);
}
}
// Handle window resizing
}
}
示例6: mouseDragged
void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
{
Window::mouseDragged(event);
if (event.getButton() == gcn::MouseEvent::LEFT)
{
if (!mItemMoved && mItemClicked)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
return;
const int itemId = mItems[mCurrentOutfit][index];
if (itemId < 0)
return;
Item *item = PlayerInfo::getInventory()->findItem(itemId);
if (item)
{
mItemMoved = item;
mItems[mCurrentOutfit][index] = -1;
}
}
if (mItemMoved)
{
mCursorPosX = event.getX();
mCursorPosY = event.getY();
}
}
}
示例7: mouseReleased
void PlayControllerZone::mouseReleased( gcn::MouseEvent& mouseEvent )
{
model().setMouse( "ZoneO",
mouseEvent.getX(),
mouseEvent.getY() );
//
// Tenemos un area para seleccionar.
adjustSelectedArea( mouseEvent.getX(),
mouseEvent.getY() );
switch ( mouseEvent.getButton() )
{
case gcn::MouseEvent::LEFT:
view().setSelectedArea( m_selectarea );
break;
case gcn::MouseEvent::RIGHT:
view().setDestination( m_selectarea );
break;
default:
break;
}
mouseEvent.consume();
}
示例8: mouseReleased
void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
{
if (event.getButton() == gcn::MouseEvent::LEFT)
{
if (itemShortcut->isItemSelected())
itemShortcut->setItemSelected(-1);
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
{
mItemMoved = NULL;
return;
}
if (mItemMoved)
{
itemShortcut->setItems(index, mItemMoved->getId());
mItemMoved = NULL;
}
else if (itemShortcut->getItem(index) && mItemClicked)
{
itemShortcut->useItem(index);
}
if (mItemClicked)
mItemClicked = false;
}
}
示例9: mouseDragged
void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
{
if (event.getButton() == gcn::MouseEvent::LEFT)
{
if (!mItemMoved && mItemClicked)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
const int itemId = itemShortcut->getItem(index);
if (index == -1 || itemId < 0)
return;
Item *item = player_node->getInventory()->findItem(itemId);
if (item)
{
mItemMoved = item;
itemShortcut->removeItem(index);
}
}
if (mItemMoved)
{
mCursorPosX = event.getX();
mCursorPosY = event.getY();
}
}
}
示例10: mouseReleased
void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event)
{
if (event.getButton() == gcn::MouseEvent::LEFT)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
if (emoteShortcut->isEmoteSelected())
emoteShortcut->setEmoteSelected(0);
if (index == -1)
{
mEmoteMoved = 0;
return;
}
if (mEmoteMoved)
{
emoteShortcut->setEmotes(index, mEmoteMoved);
mEmoteMoved = 0;
}
else if (emoteShortcut->getEmote(index) && mEmoteClicked)
{
emoteShortcut->useEmote(index + 1);
}
if (mEmoteClicked)
mEmoteClicked = false;
}
}
示例11: mousePressed
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
{
Window::mousePressed(mouseEvent);
const int x = mouseEvent.getX();
const int y = mouseEvent.getY();
Item *item = 0;
// Checks if any of the presses were in the equip boxes.
for (int i = 0; i < mBoxesNumber; ++i)
{
item = mEquipment->getEquipment(i);
gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
BOX_WIDTH, BOX_HEIGHT);
if (tRect.isPointInRect(x, y) && item)
{
setSelected(i);
break;
}
}
if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
{
if (item)
{
/* Convert relative to the window coordinates to absolute screen
* coordinates.
*/
const int mx = x + getX();
const int my = y + getY();
viewport->showPopup(this, mx, my, item, true, false);
}
}
}
示例12: mousePressed
void Window::mousePressed(gcn::MouseEvent &event)
{
// Let Guichan move window to top and figure out title bar drag
gcn::Window::mousePressed(event);
if (event.getButton() == gcn::MouseEvent::LEFT)
{
const int x = event.getX();
const int y = event.getY();
// Handle close button
if (mCloseButton)
{
gcn::Rectangle closeButtonRect(
getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(),
getPadding(),
mSkin->getCloseImage()->getWidth(),
mSkin->getCloseImage()->getHeight());
if (closeButtonRect.isPointInRect(x, y))
close();
}
// Handle window resizing
mouseResize = getResizeHandles(event);
}
}
示例13: mouseDragged
void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event)
{
if (event.getButton() == gcn::MouseEvent::LEFT)
{
if (!mEmoteMoved && mEmoteClicked)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
return;
const int emoteId = emoteShortcut->getEmote(index);
if (emoteId)
{
mEmoteMoved = emoteId;
emoteShortcut->removeEmote(index);
}
}
if (mEmoteMoved)
{
mCursorPosX = event.getX();
mCursorPosY = event.getY();
}
}
}
示例14: mouseClicked
void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
Window::mouseClicked(event);
if (event.getButton() == gcn::MouseEvent::RIGHT &&
event.getSource() == mItems)
mItems->showPopupMenu(INVENTORY);
}
示例15: mouseClicked
void LayerPanel::mouseClicked(gcn::MouseEvent& me)
{
gcn::Widget *src = me.getSource();
// poll the buttons for a click
for(uint32 i = 0; i < LAYER_MAX; i++)
{
if(src == btnLayers[i])
{
if(me.getButton() == gcn::MouseEvent::LEFT)
_engine->GetDrawPanel()->SetActiveLayer(i);
else if(me.getButton() == gcn::MouseEvent::RIGHT)
_engine->ToggleLayerVisible(i);
return;
}
}
}