1ForeverHD / TopbarPlus

Construct dynamic and intuitive topbar icons. Enhance the appearance and behaviour of these icons with features such as themes, dropdowns and menus.
https://devforum.roblox.com/t/topbarplus/1017485
Mozilla Public License 2.0
100 stars 129 forks source link

Consider Label TextBox support #27

Closed 1ForeverHD closed 5 months ago

1ForeverHD commented 3 years ago
dakaduhs commented 3 years ago

I've tried adding my own way of creating a TextBox but it just breaks the entire TopbarPlus and only basic icons are created. How would I properly go about actually adding it?

1ForeverHD commented 3 years ago

It'll likely involve converting the TextLabel into a TextButton, then a few other possible tweaks:

image

https://github.com/1ForeverHD/TopbarPlus/blob/main/src/Icon/TopbarPlusGui.lua

image

https://github.com/1ForeverHD/TopbarPlus/blob/main/src/Icon/init.lua

dakaduhs commented 3 years ago

image image

I've done exactly what you have done to try to make a normal TextLabel. There are no output errors.

image

I've checked everything by simply searching for strings of text in the editor repeating anything for a TextLabel but changing whatever I need into a TextBox. Just turns into into this: image

The open dropdown is the UI I made before the TextBox stopped making it work. By any chance, would attempting to override the TextLabel work for this method or would trying to find a way to format the TextLabel into a TextBox work better?

1ForeverHD commented 3 years ago

Between the gap at line 64 of TopbarPlusGui (ensuring a completely new clean module) add the following:

local iconBox = Instance.new("TextBox")
iconBox.BackgroundTransparency = 1
iconBox.Name = "IconBox"
iconBox.AnchorPoint = Vector2.new(0, 0.5)
iconBox.Position = UDim2.new(0.5, 0, 0.5, 0)
iconBox.Text = ""
iconBox.RichText = true
iconBox.TextScaled = false
iconBox.ClipsDescendants = true
iconBox.ZIndex = 11--3
iconBox.Parent = iconButton
iconBox.Active = false
iconBox.Visible = false

Then for every icon you wish to convert into a TextBox, do the following:

local function convertToTextBox(icon)
    icon:setInstance("iconLabel", icon.instances.iconButton.IconBox)
    icon:_updateAll()
    icon:lock()
end

Icon.new()
    :give(convertToTextBox)

In the future I'll introduce a method to handle all of this, likely called 'convertLabelToTextBox'

icon:convertLabelToTextBox

Also note that in future versions, the :give method will be renamed to :call.

dakaduhs commented 3 years ago

I never realized you were able to make your own functions and give them to the icon itself. Anyways, thanks for the help on this.

1ForeverHD commented 5 months ago

This will not be added for v3 due to limited popularity