HUD Menu, need button to preform action/command

I used the tutorial at https://forums.epicgames.com/threads/817252-Creating-Menus-Buttons-Using-Canvas to create a menu scene for my game i modified it so i could toggle it on/off and gave it a black background but pressing the button i have created does nothing. TheAgent says he was able to implement the button preforming an action by adding this to his tutorial


function CheckBounds(float MousePositionX, float MousePositionY)
{
    local float FinalRangeX;
    local float FinalRangeY;

    if(bStatic == true)
    return;

    if(bIsActive == true)
    {
       FinalRangeX = XT + Width;  //From the X position add to that the width to create a value starting from the X position to the legnth of the object.
       FinalRangeY = YL + Height; //From the Y position add to that the height to create a value starting from the Y position to the height of the object.

       //CheckMousePositionWithinBounds

       if(MousePositionX >= XT && MousePositionX <= FinalRangeX && MousePositionY >= YL && MousePositionY <= FinalRangeY  )
       {
         //`log("Within Bounds");
          bIsHighlighted = true; //Highlight Object (Switch UV Texture IDx)
           foreach ThisWorld.AllActors (class'UHUD', HUD)
	{
          if(HUD.PendingLeftPressed == true) // this was changed from if (bClicked == true)
          {
            `log("Clicked Button");
            ButtonClicked(Tag); // this was added
          }
         }
       }
       else
       {
         bIsHighlighted = false;
       }
    }
}

and


function ButtonClicked(string ETag)
{
         foreach ThisWorld.AllActors (class'UHUD', HUD)
	{
           HUD.DoButtonAction(ETag);
        }
}

which does not work for me as i get an error stating that foreach requires a iterator, but my understanding is that class object does not have a reference to WorldInfo or Actor so iterations cant be used. (and of course if im wrong correct me :smiley: ) if someone could point me in the right direction for getting my button to preform actions/commands that would be awesome!

I solved it!


function CheckBounds(float MousePositionX, float MousePositionY)
{
    local float FinalRangeX;
    local float FinalRangeY;

    local DFPlayerController PC;
	local DFHUD DHUD;

    PC = DFPlayerController(InputOwner.Outer);
	DHUD = DFHUD(PC.MyHUD);

     `log("CheckBounds Loaded!!");

    if(bIsActive == true)
    {
       FinalRangeX = XT + Width;  //From the X position add to that the width to create a value starting from the X position to the legnth of the object.
       FinalRangeY = YL + Height; //From the Y position add to that the height to create a value starting from the Y position to the height of the object.

       //CheckMousePositionWithinBounds

       if(MousePositionX &gt;= XT && MousePositionX &lt;= FinalRangeX && MousePositionY &gt;= YL && MousePositionY &lt;= FinalRangeY  )
       {
         //`log("Within Bounds");
          bIsHighlighted = true; //Highlight Object (Switch UV Texture IDx)
          if (DHUD.PendingLeftPressed != false)
          {
            `log("Clicked Button");
            ButtonClicked(Tag);
          }
       }
       else
       {
         bIsHighlighted = false;
       }
    }
}


function ButtonClicked(string ETag)
{
    local DFPlayerController PC;
    local DFHUD DHUD;

    PC = DFPlayerController(InputOwner.Outer);
    DHUD = DFHUD(PC.MyHUD);

    if( PC != none )
    {
        DHUD.DoButtonAction(ETag);
    }
}