Browse Source

Windows touch with CallOutBox bug fix

tags/2021-05-28
ed 9 years ago
parent
commit
cbdf707116
3 changed files with 24 additions and 4 deletions
  1. +1
    -2
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp
  2. +18
    -1
      modules/juce_gui_basics/windows/juce_CallOutBox.cpp
  3. +5
    -1
      modules/juce_gui_basics/windows/juce_CallOutBox.h

+ 1
- 2
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -1967,8 +1967,7 @@ private:
{
bool isCancel = false;
// touchIndex zero is reserved for the mouse
const int touchIndex = currentTouches.getIndexOfTouch (touch.dwID) + 1;
const int touchIndex = currentTouches.getIndexOfTouch (touch.dwID);
const int64 time = getMouseEventTime();
const Point<float> pos (globalToLocal (Point<float> (touch.x / 100.0f,
touch.y / 100.0f)));


+ 18
- 1
modules/juce_gui_basics/windows/juce_CallOutBox.cpp View File

@@ -41,7 +41,11 @@ CallOutBox::CallOutBox (Component& c, const Rectangle<int>& area, Component* con
.getDisplayContaining (area.getCentre()).userArea);
addToDesktop (ComponentPeer::windowIsTemporary);
startTimer (100);
}
creationTime = Time::getCurrentTime();
}
CallOutBox::~CallOutBox()
@@ -129,7 +133,14 @@ void CallOutBox::inputAttemptWhenModal()
// if you click on the area that originally popped-up the callout, you expect it
// to get rid of the box, but deleting the box here allows the click to pass through and
// probably re-trigger it, so we need to dismiss the box asynchronously to consume the click..
dismiss();
// For touchscreens, we make sure not to dismiss the CallOutBox immediately,
// as Windows still sends touch events before the CallOutBox had a chance
// to really open.
RelativeTime elapsed = Time::getCurrentTime() - creationTime;
if (elapsed.inMilliseconds() > 200)
dismiss();
}
else
{
@@ -240,3 +251,9 @@ void CallOutBox::refreshPath()
targetPoint - getPosition().toFloat(),
9.0f, arrowSize * 0.7f);
}
void CallOutBox::timerCallback()
{
toFront (true);
stopTimer();
}

+ 5
- 1
modules/juce_gui_basics/windows/juce_CallOutBox.h View File

@@ -53,7 +53,8 @@
The call-out will resize and position itself when the content changes size.
*/
class JUCE_API CallOutBox : public Component
class JUCE_API CallOutBox : public Component,
private Timer
{
public:
//==============================================================================
@@ -173,7 +174,10 @@ private:
Image background;
bool dismissalMouseClicksAreAlwaysConsumed;
Time creationTime;
void refreshPath();
void timerCallback() override;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CallOutBox)
};


Loading…
Cancel
Save