WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   ChatFrame1EditBox Resizing and Scrolling (https://www.wowinterface.com/forums/showthread.php?t=58603)

BloodLilly 02-23-21 01:07 PM

ChatFrame1EditBox Resizing and Scrolling
 
1 Attachment(s)
Hello, I've searched this forum and the internet for a potential addon that would be what I'm looking for. However, I couldn't find anything after installing and uninstalling a lot of addons, nothing fit the bill. So I thought I would look around for code with the intention of making my own addon, however, I am not a coder. I have extremely little experience in coding and a lot of the code strings I see, don't explain what else you need to make the file work.

My intention is to make the 'ChatFrame1EditBox' adjustable in height. However I wish to do this with the parameter that it would be set to the number of lines that would fit in vertically.

For example, you would set the 'Height' to '4' and this would allow 4 lines of text to be written in the edit box in a Multi-line way. Then the section that states the Channel you are writing in, stays at the bottom left of the EditBox.

Beyond this, if a user were to time more than 4 lines after setting it to that height, the text would then scroll vertically, as opposed to it's default horizontally.

I have attached an image of what I'd like the final product to look like. I just have no idea where to start.

Code that I have tried is here

Main.lua
Code:

ChatFrame1EditBox:SetHeight(20)

ChatFrame1EditBoxLeft:SetSize(20, 20)
ChatFrame1EditBoxRight:SetSize(20, 20)
ChatFrame1EditBoxMid:SetHeight(20)

ChatFrame1EditBoxFocusLeft:SetSize(20, 20)
ChatFrame1EditBoxFocusRight:SetSize(20, 20)
ChatFrame1EditBoxFocusMid:SetHeight(20)

ChatFrame1EditBoxLanguage:SetSize(20, 20)

ChatExtender.toc
Code:

## Interface: 90002
## Title: Chatextender
## Author: BloodLilly
## Version: 1.0

Main.lua

Any help would be great. I have looked at tutorials, however, a lot of them don't state what it is I am looking for. So if you do provide a tutorial, can you please let me know which section I should pay attention to.

Edit:

I have recently found this piece of code, that allows the Edit Box to be longer and am currently seeing of I can make it taller instead of longer. But I'm still unsure how to.

Code:

function LargerChatInput_OnLoad(self)
    self:RegisterEvent("ADDON_LOADED")
end


function LargerChatInput_OnEvent(self, event, ...)
    if event == "ADDON_LOADED" then
        local addon = ...
        if addon == "LargerChatInput" then
            LargerChatInput_OnLoaded()
            self:UnregisterEvent("ADDON_LOADED")
        end
    end
end


function LargerChatInput_OnLoaded()
    hooksecurefunc(
        ChatFrame1EditBox,
        "Show",
        function()
            local left = ChatFrame1:GetLeft()
            local width = GetScreenWidth() - left - 5
            ChatFrame1EditBox:SetPoint("RIGHT", ChatFrame1, "LEFT", width, 0)
        end
    )
end


Fizzlemizz 02-23-21 01:58 PM

Code:

ChatFrame1EditBox:SetMultiLine(true)
How it scrolls depends on how it's anchored.
It also alters some functionality like history scrolling.

BloodLilly 02-23-21 03:32 PM

1 Attachment(s)
How would I anchor it so that it scrolls?

I've managed to get it done to a standard using in-game commands. Attached is an image of how it looks. However, I can't seem to get it running as an addon.

Code:

/run local editBox = DEFAULT_CHAT_FRAME.editBox; editBox:ClearAllPoints();
editBox:SetPoint("TOPLEFT",ChatFrame1,"TOPRIGHT",0,0);
editBox:SetPoint("BOTTOMLEFT",ChatFrame1,"BOTTOMRIGHT",0,-3);
editBox:SetPoint("TOPLEFT",ChatFrame1,"BOTTOMLEFT",0,-93);
editBox:SetPoint("TOPRIGHT",ChatFrame1,"BOTTOMRIGHT",23,100);
ChatFrame1EditBox:SetMultiLine(true)

I have no idea how to make this into an addon that runs when you load into the game.
It works as you put it in the chat window like that, but obviously it always resets when you reload ui

Fizzlemizz 02-23-21 04:07 PM

Your macro is doing 4 SetPoint calls for the editbox. Maybe something like:

Lua Code:
  1. ChatFrame1EditBox:SetMultiLine(true)
  2. ChatFrame1EditBox:ClearAllPoints()
  3. ChatFrame1EditBox:SetPoint("BOTTOMLEFT", UIParent)
  4. ChatFrame1EditBox:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMLEFT", 250, 0)

The box should resize as you type more lines. It's been a while since I played with this.

You should be able to place this in your main.lua file.

BloodLilly 02-23-21 04:34 PM

1 Attachment(s)
Yeah, it's doing that because I want the editbox to be a set size, or if it expands with more lines, doesn't go beyond that size. If there are more lines after that, the lettering would scroll within the box.

I'm trying to figure out a way to have the text scroll within the set edit frame box.

EDIT:

Okay, so after reloading a few times, the Addon works... Kinda. But it's doing what you said now and is acting in the way that the more you type the bigger the box gets. However, this isn't what I want as it'll end up covering the chat box and cover previous messages, that I may be replying to. I'd like it to stay at the static fixed size and the text to scroll within it.

EDIT2:

I've added an image of what it looks like when the addon loads up. As you can see there's now a massive gap beneath the chat box and the edit box, This is also what happens when I also use your code Fizzlemizz. The only problem is, it's not really what I want it to do.

EDIT3:

I'm not quite sure why running:

Code:

/run local editBox = DEFAULT_CHAT_FRAME.editBox; editBox:ClearAllPoints();
editBox:SetPoint("TOPLEFT",ChatFrame1,"TOPRIGHT",0,0);
editBox:SetPoint("BOTTOMLEFT",ChatFrame1,"BOTTOMRIGHT",0,-3);
editBox:SetPoint("TOPLEFT",ChatFrame1,"BOTTOMLEFT",0,-93);
editBox:SetPoint("TOPRIGHT",ChatFrame1,"BOTTOMRIGHT",23,0);
ChatFrame1EditBox:SetMultiLine(true)

In the in-game chat, causes the option I prefer (The image from my second post) and running:

Code:

ChatFrame1EditBox:ClearAllPoints();
ChatFrame1EditBox:SetPoint("TOPLEFT",ChatFrame1,"TOPRIGHT",0,0);
ChatFrame1EditBox:SetPoint("BOTTOMLEFT",ChatFrame1,"BOTTOMRIGHT",0,-3);
ChatFrame1EditBox:SetPoint("TOPLEFT",ChatFrame1,"BOTTOMLEFT",0,-93);
ChatFrame1EditBox:SetPoint("TOPRIGHT",ChatFrame1,"BOTTOMRIGHT",23,0);
ChatFrame1EditBox:SetMultiLine(true)

Causes the outcome that I'm not to keen on (The image in the post)

EDIT4:

So I managed to get it to load the way I wanted to, now I just need to see if I can find out how to do the scrolling bit.

Code:

local frame=CreateFrame("Frame");
frame:RegisterEvent("PLAYER_LOGIN");
frame:SetScript("OnEvent",function(self,event,...)
local editBox = DEFAULT_CHAT_FRAME.editBox; editBox:ClearAllPoints()
editBox:SetPoint("TOPLEFT",ChatFrame1,"TOPRIGHT",0,0)
editBox:SetPoint("BOTTOMLEFT",ChatFrame1,"BOTTOMRIGHT",0,-3)
editBox:SetPoint("TOPLEFT",ChatFrame1,"BOTTOMLEFT",0,-93)
editBox:SetPoint("TOPRIGHT",ChatFrame1,"BOTTOMRIGHT",23,0)
ChatFrame1EditBox:SetMultiLine(true)
end);


Fizzlemizz 02-24-21 10:06 AM

I was thinking something like:
Lua Code:
  1. local frame=CreateFrame("Frame")
  2. frame:RegisterEvent("PLAYER_LOGIN")
  3. frame:SetScript("OnEvent",function(self,event,...)
  4.     local chat = DEFAULT_CHAT_FRAME
  5.     local editBox = chat.editBox
  6.     editBox:ClearAllPoints()
  7.     local x = chat:GetLeft()
  8.     local y = chat:GetBottom() - editBox:GetHeight()
  9.     editBox:SetPoint("BOTTOMLEFT", UIParent ,x ,y)
  10.     editBox:SetWidth(chat:GetWidth())
  11.     editBox:SetMultiLine(true)
  12.     local n = editBox:GetName()
  13.     _G[n.."Left"]:Hide()
  14.     _G[n.."Mid"]:Hide()
  15.     _G[n.."Right"]:Hide()
  16.     editBox.focusLeft:SetTexture(nil)
  17.     editBox.focusMid:SetTexture(nil)
  18.     editBox.focusRight:SetTexture(nil)
  19. end)
The editbox artwork doesn't adjust so I've just hidden it (some of the artwork regions might not be valid in Classic)

BloodLilly 02-26-21 04:29 AM

Thank you very much for looking into it further. That does solve the problem of it going off screen as the lettering moves up into the screen as opposed to down and off the screen. But it still ends up covering the chat. I'm still using the previous one I stated, that has the box at a set height, and it's been working really well. However, I still would like to try and get a text scrolling function that would fit into the set box.


All times are GMT -6. The time now is 05:31 AM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI