Download

Slate Widget Coordinate

Trying to detect when the user’s cursor hovers over a SButton widget.

I can get the user’s mouse coordinates but not sure how I’d determine an SButton’s x/y/width/height so that I can test if the cursor is within?

Anyone have any suggestions or should I just redesign my UI?

Make sure you are extending your own widget class from SCompoundWidget

Check out SWidget.h !

It has all the functions you could ever want for what you are asking

UE4 does it for you already

check these ones out:


/** @return True if this widget hovered */
	**virtual bool IsHovered() const**
	{
		return bIsHovered;
	}

/**
	 * Set the tool tip that should appear when this widget is hovered.
	 *
	 * @param InToolTipText  the text that should appear in the tool tip
	 */
	**void SetToolTipText( const TAttribute<FString>& InToolTipText );**

	**void SetToolTipText( const FText& InToolTipText );**

/** @return The index of the child that the mouse is currently hovering */
	static int32 **FindChildUnderMouse**( const FArrangedChildren& Children, const FPointerEvent& MouseEvent );

/**
	 * The system calls this method to notify the widget that a mouse moved within it. This event is bubbled.
	 *
	 * @param MyGeometry The Geometry of the widget receiving the event
	 * @param MouseEvent Information about the input event
	 *
	 * @return Whether the event was handled along with possible requests for the system to take action.
	 */
	virtual FReply **OnMouseMove**( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent );
	
	/**
	 * The system will use this event to notify a widget that the cursor has entered it. This event is NOT bubbled.
	 *
	 * @param MyGeometry The Geometry of the widget receiving the event
	 * @param MouseEvent Information about the input event
	 */
	virtual void **OnMouseEnter**( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent );
	
	/**
	 * The system will use this event to notify a widget that the cursor has left it. This event is NOT bubbled.
	 *
	 * @param MouseEvent Information about the input event
	 */
	virtual void **OnMouseLeave**( const FPointerEvent& MouseEvent );
	
	/**
	 * Called when the mouse wheel is spun. This event is bubbled.
	 *
	 * @param  MouseEvent  Mouse event
	 *
	 * @return  Returns whether the event was handled, along with other possible actions
	 */
	virtual FReply **OnMouseWheel**( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent );

Hey its Rama!

Thanks for the direction, looks like SWidget has everything I need. Don’t know why I trusted intellisense instead of checking out the engine source.

Really appreciate all the work you’ve done in the community Rama, hoping I can learn enough to pay it forward some day!