Browse Source

Remove Event::PreventDefault(), it is not working as one might expect from the name.

Michael Ragazzon 6 years ago
parent
commit
c76723803d

+ 0 - 5
Include/RmlUi/Core/Event.h

@@ -86,8 +86,6 @@ public:
 	void StopPropagation();
 	/// Stops propagation of the event if it is interruptible, including to any other listeners on the current element.
 	void StopImmediatePropagation();
-	/// Prevents the default actions from being performed.
-	void PreventDefault();
 
 	/// Returns true if the event can be interrupted, that is, stopped from propagating.
 	bool IsInterruptible() const;
@@ -95,8 +93,6 @@ public:
 	bool IsPropagating() const;
 	/// Returns true if the event is still immediate propagating.
 	bool IsImmediatePropagating() const;
-	/// Returns true if the default actions to be executed by this event has been prevented.
-	bool IsDefaultPrevented() const;
 
 	/// Checks if the event is of a certain type.
 	/// @param type The name of the type to check for.
@@ -141,7 +137,6 @@ private:
 	
 	bool interrupted;
 	bool interrupted_immediate;
-	bool default_prevented;
 
 	bool has_mouse_position;
 	Vector2f mouse_screen_position;

+ 0 - 1
Source/Core/Element.cpp

@@ -1815,7 +1815,6 @@ void Element::ProcessDefaultAction(Event& event)
 				// This prevents scrolling in parent elements, which is often unintended. If instead desired behavior is
 				// to scroll in parent elements when reaching top/bottom, move StopPropagation inside the next if statement.
 				event.StopPropagation();
-				event.PreventDefault();
 
 				const float wheel_delta = event.GetParameter< float >("wheel_delta", 0.f);
 

+ 0 - 12
Source/Core/Event.cpp

@@ -40,7 +40,6 @@ Event::Event() : id(EventId::Invalid)
 	interruptible = false;
 	interrupted = false;
 	interrupted_immediate = false;
-	default_prevented = false;
 	current_element = nullptr;
 	target_element = nullptr;
 	has_mouse_position = false;
@@ -53,7 +52,6 @@ Event::Event(Element* _target_element, EventId id, const String& type, const Dic
 	phase = EventPhase::None;
 	interrupted = false;
 	interrupted_immediate = false;
-	default_prevented = false;
 	current_element = nullptr;
 
 	has_mouse_position = false;
@@ -136,11 +134,6 @@ bool Event::IsImmediatePropagating() const
 	return !interrupted_immediate;
 }
 
-bool Event::IsDefaultPrevented() const
-{
-	return default_prevented;
-}
-
 bool Event::IsInterruptible() const
 {
 	return interruptible;
@@ -155,11 +148,6 @@ void Event::StopImmediatePropagation()
 	}
 }
 
-void Event::PreventDefault()
-{
-	default_prevented = true;
-}
-
 const Dictionary& Event::GetParameters() const
 {
 	return parameters;

+ 1 - 1
Source/Core/EventDispatcher.cpp

@@ -210,7 +210,7 @@ bool EventDispatcher::DispatchEvent(Element* target_element, const EventId id, c
 	// Process the default actions.
 	for (auto& element_ptr : default_action_elements)
 	{
-		if (event->IsDefaultPrevented())
+		if (!event->IsPropagating())
 			break;
 
 		if (Element* element = element_ptr.get())

+ 0 - 1
Source/Debugger/ElementInfo.cpp

@@ -339,7 +339,6 @@ void ElementInfo::ProcessEvent(Core::Event& event)
 				if (new_source_element != source_element)
 				{
 					SetSourceElement(new_source_element);
-					event.StopPropagation();
 				}
 			}
 		}