rmb drag-drop is now using proper rmb-down detection

This commit is contained in:
sruz25 2014-09-20 17:58:22 +02:00 committed by simon
parent 688069c913
commit 557d2736cf
2 changed files with 6 additions and 19 deletions

View File

@ -93,7 +93,6 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
,m_JavaDialogFieldName(L"")
#endif
{
m_rmb_down = false;
current_keys_pending.key_down = false;
current_keys_pending.key_up = false;
current_keys_pending.key_enter = false;
@ -2949,8 +2948,8 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
if((event.EventType==EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event != EMIE_MOUSE_MOVED) ||
(event.MouseInput.Event == EMIE_MOUSE_MOVED &&
m_rmb_down && getItemAtPos(m_pointer).i != getItemAtPos(m_last_pointer).i)){
// Mouse event other than movement
event.MouseInput.isRightPressed() && getItemAtPos(m_pointer).i != getItemAtPos(m_old_pointer).i)){
// Mouse event other than movement or crossing the border of inventory field while holding rmb
// Get selected item and hovered/clicked item (s)
@ -3006,7 +3005,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
(m_selected_item->i == s.i);
// buttons: 0 = left, 1 = right, 2 = middle
// up/down: 0 = down (press), 1 = up (release), 2 = unknown event
// up/down: 0 = down (press), 1 = up (release), 2 = unknown event, -1 movement
int button = 0;
int updown = 2;
if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
@ -3024,17 +3023,6 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
else if(event.MouseInput.Event == EMIE_MOUSE_MOVED)
{ updown = -1;}
if(button == 1){ //catch the change of state of rmb (TODO: maybe there's cleaner way to determine if rmb is down?)
switch (updown) {
case 0:
m_rmb_down = true;
break;
case 1:
m_rmb_down = false;
break;
}
}
// Set this number to a positive value to generate a move action
// from m_selected_item to s.
u32 move_amount = 0;
@ -3126,7 +3114,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
}
else if(updown == -1) {
//mouse has been moved and rmb is down and mouse pointer just entered now inventory field
//(checked in the entry if, this is the only action here that is generated by mouse movement)
//(checked in the entry-if, this is the only action here that is generated by mouse movement)
if(m_selected_item != NULL && s.isValid()){
move_amount = 1; //move 1 iteam, TODO: mmb to move 10 iteams might be handy
}
@ -3230,7 +3218,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
m_selected_dragging = false;
m_selected_content_guess = ItemStack();
}
m_last_pointer = m_pointer;
m_old_pointer = m_pointer;
}
if(event.EventType==EET_GUI_EVENT) {

View File

@ -298,8 +298,6 @@ protected:
std::string m_formspec_string;
InventoryLocation m_current_inventory_location;
v2s32 m_last_pointer;//mouse position after previous mouse event
bool m_rmb_down;//determined by catching rmb pressed/released button (TODO: maybe there's cleaner way to do it?)
std::vector<ListDrawSpec> m_inventorylists;
std::vector<ImageDrawSpec> m_backgrounds;
@ -323,6 +321,7 @@ protected:
InventoryLocation m_selected_content_guess_inventory;
v2s32 m_pointer;
v2s32 m_old_pointer;//mouse position after previous mouse event
gui::IGUIStaticText *m_tooltip_element;
u32 m_tooltip_show_delay;