Skip to content

Commit

Permalink
Fixed bugs in WindowAddHotspot regarding mouse-move events
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Jul 19, 2011
1 parent 38182a9 commit b5472a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
34 changes: 17 additions & 17 deletions scripting/methods/methods_miniwindows.cpp
Expand Up @@ -542,6 +542,14 @@ long CMUSHclientDoc::WindowAddHotspot(LPCTSTR Name,
if (it == m_MiniWindows.end ())
return eNoSuchWindow;

static bool bInWindowAddHotspot = false;

// don't recurse into infinite loops
if (bInWindowAddHotspot)
return eItemInUse;

bInWindowAddHotspot = true;

string sPluginID;

if (m_CurrentPlugin)
Expand All @@ -565,25 +573,17 @@ long CMUSHclientDoc::WindowAddHotspot(LPCTSTR Name,
// in mouse was over hotspot when it was created, do a "mouse move" to detect this
if (status == eOK)
{
MiniWindowMapIterator it = m_MiniWindows.find (Name);
if (it != m_MiniWindows.end ())
{
CMiniWindow * mw = it->second;

for(POSITION pos=GetFirstViewPosition();pos!=NULL;)
{
CView* pView = GetNextView(pos);

if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView)))
{
CMUSHView* pmyView = (CMUSHView*)pView;
pmyView->Mouse_Move_MiniWindow (this,
CPoint (mw->m_last_mouseposition.x + mw->m_rect.left, mw->m_last_mouseposition.y + mw->m_rect.top) );
}
} // end of looping through views
} // end of miniwindow still exists
for(POSITION pos=GetFirstViewPosition();pos!=NULL;)
{
CView* pView = GetNextView(pos);

if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView)))
((CMUSHView*)pView)->Mouse_Move_MiniWindow (this, m_lastMousePosition);
} // end of looping through views
} // end of added hotspot OK

bInWindowAddHotspot = false;

return status;

} // end of CMUSHclientDoc::WindowHotspot
Expand Down
4 changes: 3 additions & 1 deletion stdafx.h
Expand Up @@ -662,8 +662,10 @@ inline string trim_right (const string & s, const string & t = SPACES)
string::size_type i (d.find_last_not_of (t));
if (i == string::npos)
return "";
else if ((i + 1) >= s.size ())
return s;
else
return d.erase (d.find_last_not_of (t) + 1) ;
return d.erase (i + 1) ;
} // end of trim_right

inline string trim_left (const string & s, const string & t = SPACES)
Expand Down

0 comments on commit b5472a4

Please sign in to comment.