wow lua multi line edit with scroll
- User
wow lua multi line edit with scroll
- Assistant
To achieve multi-line editing with scrolling in Lua, you can make use of libraries such as "ncurses" or "fzf".
Here's an example using the "ncurses" library:
local curses = require("ncurses") -- Initialize ncurses curses.initscr() curses.cbreak() curses.echo(false) curses.nl(false) curses.raw() -- Get screen dimensions local rows, cols = curses.LINES(), curses.COLS() -- Create a new window local win = curses.newwin(rows, cols, 0, 0) -- Enable keypad input win:keypad(true) -- Display a multiline text local text = [[ This is line 1. This is line 2. This is line 3. This is line 4. This is line 5. This is line 6. This is line 7. This is line 8. This is line 9. This is line 10. This is line 11. This is line 12. This is line 13. This is line 14. This is line 15. This is line 16. This is line 17. This is line 18. This is line 19. This is line 20. ]] win:mvprintw(0, 0, text) win:refresh() -- Multi-line editing with scrolling local line = 0 local max_line = #text:split("\n") while true do local key = win:getch() if key == curses.KEY_UP then if line > 0 then line = line - 1 end elseif key == curses.KEY_DOWN then if line < max_line - rows then line = line + 1 end elseif key == curses.KEY_ENTER or key == 10 then break end -- Clear the window win:clear() -- Print the multiline text with scrolling local start_line = line + 1 local end_line = line + rows local lines = text:split("\n", start_line, end_line) for i, line in ipairs(lines) do win:mvprintw(i - 1, 0, line) end -- Refresh the window win:refresh() end -- End ncurses mode curses.endwin() - User
world of warraft lua multi line edit with scroll
- Assistant
- User
add link to EditBox
- Assistant
To add a clickable link to the EditBox in the World of Warcraft Lua code, you can use the
Insert()method provided by the EditBox widget.Here's an example of how to add a clickable link to the EditBox:
local MyTextFrame = CreateFrame("EditBox", "MyTextFrame", UIParent) MyTextFrame:SetMultiLine(true) MyTextFrame:SetAutoFocus(false) MyTextFrame:SetFontObject("GameFontHighlight") MyTextFrame:SetSize(300, 200) MyTextFrame:SetPoint("CENTER", 0, 0) MyTextFrame:SetText("This is a link: |Hurl:https://www.example.com|h[Click Here!]|h") -- Set up the event handler for hyperlink clicks MyTextFrame:SetScript("OnHyperlinkClick", function(self, linkData, linkText, button) local linkType, linkValue = linkData:match("(%a+):(.+)") if linkType == "url" then ChatFrame1:AddMessage("URL clicked: " .. linkValue) -- Open the URL in a web browser LoadURL(linkValue) return true end end) - User
add link of spell to EditBox
- Assistant
To add a clickable link of a spell to the EditBox in World of Warcraft Lua code, you can use the
Insert()method provided by the EditBox widget.Here's an example of how to add a clickable link of a spell to the EditBox:
local spellName = "Fireball" -- Replace with the desired spell name local spellLink = GetSpellLink(spellName) if spellLink then local MyTextFrame = CreateFrame("EditBox", "MyTextFrame", UIParent) MyTextFrame:SetMultiLine(true) MyTextFrame:SetAutoFocus(false) MyTextFrame:SetFontObject("GameFontHighlight") MyTextFrame:SetSize(300, 200) MyTextFrame:SetPoint("CENTER", 0, 0) MyTextFrame:Insert(spellLink) -- Set up the event handler for hyperlink clicks MyTextFrame:SetScript("OnHyperlinkClick", function(self, linkData, linkText, button) local linkType, linkValue = linkData:match("(%a+):(.+)") if linkType == "spell" then local spellID = tonumber(linkValue) -- Handle the spell link click, use the spellID if needed print("Spell clicked: " .. GetSpellInfo(spellID)) return true end end) end - User
set link to ItemRefTooltip and show it
- Assistant
To set a clickable link to
ItemRefTooltipand show the tooltip when the link is clicked in World of Warcraft Lua code, you can override theSetHyperlinkmethod ofItemRefTooltipframe and callShowto display the tooltip.Here's an example of how to set a clickable link to the
ItemRefTooltipand show it:local link = "|cffffffff|Hitem:6948::::::::60:::::::|h[Hearthstone]|h|r" -- Override the SetHyperlink method of ItemRefTooltip ItemRefTooltip.SetHyperlink = function(self, link) self:SetOwner(UIParent, "ANCHOR_PRESERVE") self:SetHyperlink(link) self:Show() end -- Create a button to test the tooltip local button = CreateFrame("Button", "MyButton", UIParent, "UIPanelButtonTemplate") button:SetSize(100, 30) button:SetPoint("CENTER", 0, 0) button:SetText("Show Item Tooltip") button:SetScript("OnClick", function() ItemRefTooltip:SetHyperlink(link) end) - User
set link to GameTooltip and show it
- Assistant
To set a clickable link to
GameTooltipand show it when the link is clicked in World of Warcraft Lua code, you can use theSetHyperlinkmethod ofGameTooltipto display the tooltip.Here's an example of how to set a clickable link to
GameTooltipand show it:local link = "|cffffffff|Hitem:6948::::::::60:::::::|h[Hearthstone]|h|r" -- Create a button to test the tooltip local button = CreateFrame("Button", "MyButton", UIParent, "UIPanelButtonTemplate") button:SetSize(100, 30) button:SetPoint("CENTER", 0, 0) button:SetText("Show Item Tooltip") button:SetScript("OnClick", function() GameTooltip:SetOwner(button, "ANCHOR_RIGHT") GameTooltip:SetHyperlink(link) GameTooltip:Show() end)In this example, we have a variable
linkthat represents the item link (again, a Hearthstone item link). When the button is clicked, we call theSetOwnermethod ofGameTooltipto set the tooltip's owner, then useSetHyperlinkto set the tooltip's content to the provided link. Finally, we call to display the tooltip.