ScaleformUI icon indicating copy to clipboard operation
ScaleformUI copied to clipboard

Radio menu staying open?

Open GLiTcH2 opened this issue 1 year ago • 0 comments

I wanted to mess around with the radio menu and copied the code from the example to make my own menu, This is what I copied (Except for the bottom code, Added a bit to use a button/key combo to open it instead of single) :

function CreateRadioMenu()
	
    local txd = CreateRuntimeTxd("scaleformui")
	local imgdui1 = CreateDui("https://giphy.com/embed/10bTCLE8GtHHS8", 96, 64)
	CreateRuntimeTextureFromDuiHandle(txd, "item2", GetDuiHandle(imgdui1))
	local menu = UIRadioMenu.New()
	menu:AnimationDuration(1.0)
	menu:AnimDirection(-1)
	for i=1, 25, 1 do
		local item = RadioItem.New("Station " .. i, "Artist " .. i, "Track " .. i, "scaleformui", "item2")
		menu:AddStation(item)
	end
	menu.OnMenuOpen = function(menu, _)
		ScaleformUI.Notifications:ShowSubtitle("Radio Menu opened!")
	end

	menu.OnMenuClose = function(menu)
		ScaleformUI.Notifications:ShowSubtitle("Radio Menu closed!")
	end

	menu.OnIndexChange = function(index)
		ScaleformUI.Notifications:ShowSubtitle("Index ".. index .. " highlighted!")
	end

	menu.OnStationSelect = function(station, index)
		ScaleformUI.Notifications:ShowSubtitle("Selected station with index" .. index .. "!")
	end

	menu:Visible(true)

end

Citizen.CreateThread(function()
	while true do
		Wait(0)
		if IsControlPressed(0, 206) and IsControlJustPressed(0, 204) and not MenuHandler:IsAnyMenuOpen() then
			CreateRadialMenu()
		end
	end
end)

I wanted to test it in game to make sure it works and it does but once I open the menu and then close it, While it visibly closes on the screen it's like invisible in the background and if I move the analog stick on controller or use the mouse, It just keeps selecting the different stations/index. Once this happens I cant open the menu back up at all unless I restart the resource. Did I miss something from the example that I needed to copy in order to have it close properly?

GLiTcH2 avatar Feb 14 '24 17:02 GLiTcH2