- Joined
- Jul 18, 2010
- Messages
- 1,743
Introduction
In the UI-frame natives, tooltips are frames that are on default hidden. When one hovers the frame the tooltip is assigned to, the tooltip becomes visible. Tooltips itself are also frames that can have childs and be customized.That is the native one uses to make a tooltip-Frame become some frames tooltip.
BlzFrameSetTooltip takes framehandle frame, framehandle tooltip returns nothing
SimpleFrames and Tooltips
SimpleFrames can normally not have tooltips and they can also not be a tooltip for Frames. A SIMPLEBUTTON can have other SimpleFrames as tooltip.One can give a SimpleFrame a tooltip by creating a substitute FRAME which copies all points of the simpleframe. That substitute only handles the tooltip and is empty. When one hovers the SimpleFrame the substitute FRAME kicks in and shows its tooltip giving the feeling that it is the SimpleFrames tooltip. That way also SimpleFrames or BACKDROPs can have tooltips.
Example 1
In example 1, we create 3 Frames: a BACKDROP, a TEXT and a FRAME. The BACKDROP shows a Paladin icon. The FRAME copies the points of the BACKDROP and handles the Tooltip showing. As last the TEXT-Frame is the tooltip itself which is shown when one hovers the Paladin icon with the mouse.The FRAME is needed in this example because BACKDROPs can not have events nor tooltips. FRAME can't have events either but can have a tooltip.
In this example all frames are created with BlzCreateFrameByType, that is done so one does not have to bother fdf for this example.
BlzCreateFrameByType takes string typeName, string name, framehandle owner, string inherits, integer createContext
Lua:
function Face()
local face = BlzCreateFrameByType("BACKDROP", "Face", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)--Create a new frame of Type BACKDROP
local faceHover = BlzCreateFrameByType("FRAME", "FaceFrame", face,"", 0) --face is a BACKDROP it can not have events nor a tooltip, thats why one creates an empty frame managing that.
local tooltip = BlzCreateFrameByType("TEXT", "FaceFrameTooltip", face,"", 0)--Create a new frame of Type TEXT
--faceHover would be unneeded if face would support events/tooltip
BlzFrameSetAllPoints(faceHover, face) --faceHover copies the size and position of face.
BlzFrameSetTooltip(faceHover, tooltip) --when faceHover is hovered with the mouse frame tooltip becomes visible.
BlzFrameSetSize(face, 0.04, 0.04)
BlzFrameSetAbsPoint(face, FRAMEPOINT_CENTER, 0.4, 0.3)
BlzFrameSetAbsPoint(tooltip, FRAMEPOINT_CENTER, 0.2, 0.3)
BlzFrameSetText(tooltip, "Human Paladin Face")
BlzFrameSetTexture(face, "ReplaceableTextures\\CommandButtons\\BTNHeroPaladin",0, true)--face uses paladin blp as texture.
end
That code has to be executed. It does not run by itself.
-
Start
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Custom script: Face()
-
-
Example 2
The tooltip in the previous example is not really good looking, it's just some Text on the screen. I want it to be in a box and look similar to the default tooltip. Well because such a frame does not exist in the default fdf and one can not manipulate the shown text of the default tooltip frame (as far as I know), one has to create it.That will be our Boxed Text fdf. "BoxedText" is the frame we create. What can that "BoxedText" do? It mimics the default Tooltip-Box and has 2 children: "BoxedTextTitle" and "BoxedTextValue". The title is shown in the first line and below that title BoxedTextValue will be placed. BoxedTextValue has a smaller Text size than BoxedTextTitle.
Code:
// -- LOCAL TEMPLATES -------------------------------------------------------
Frame "BACKDROP" "BoxedTextBackgroundTemplate" {
DecorateFileNames, //Look-Up Names in some String table (for example gameinterface)
BackdropTileBackground, //Tile mode enabled
BackdropBackground "ToolTipBackground", //BackgroundFile
BackdropCornerFlags "UL|UR|BL|BR|T|L|B|R",
BackdropCornerSize 0.008, //higher numbers make the corners bigger.
BackdropBackgroundInsets 0.0022 0.0022 0.0022 0.0022, //makes the background smaller, from the outside.
BackdropEdgeFile "ToolTipBorder", //the border File
BackdropBlendAll,
}
// -- Frames -------------------------------------------------------
Frame "BACKDROP" "BoxedText" INHERITS "BoxedTextBackgroundTemplate" {
UseActiveContext,
Frame "TEXT" "BoxedTextTitle" {
UseActiveContext,
DecorateFileNames,
SetPoint TOPLEFT, "BoxedText", TOPLEFT, 0.005, -0.005, //Positionate "BoxedTextSimpleTitle"'s TOPLEFT to "BoxedText"'s TOPLEFT with an offset
SetPoint TOPRIGHT, "BoxedText", TOPRIGHT, -0.005, -0.005,
FontFlags "FIXEDSIZE",
FrameFont "MasterFont", 0.014, "",
FontColor 1.0 1.0 1.0 1.0, //Red Green Blue Alpha 0.0 to 1.0
FontShadowColor 0.0 0.0 0.0 0.9,
FontShadowOffset 0.001 -0.001,
}
Frame "TEXT" "BoxedTextValue" {
UseActiveContext,
DecorateFileNames,
SetPoint TOPLEFT, "BoxedText", TOPLEFT, 0.005, -0.02,
SetPoint BOTTOMRIGHT, "BoxedText", BOTTOMRIGHT, -0.005, 0.005,
FontFlags "FIXEDSIZE",
FrameFont "MasterFont", 0.012, "",
FontColor 1.0 1.0 1.0 1.0,
FontShadowColor 0.0 0.0 0.0 0.9,
FontShadowOffset 0.001 -0.001,
}
}
Now we need to change the code a bit. Instead of TEXT, we now create a Frame of name "BoxedText". Also the tooltip is not a TEXT anymore, it's now a box, means we have to access the children of the box showing the text. They are BoxedTextValue and BoxedTextTitle.
Lua:
function Face2()
BlzLoadTOCFile("war3mapimported\\BoxedText.toc")
local face = BlzCreateFrameByType("BACKDROP", "Face", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)--Create a new frame of Type BACKDROP
local faceHover = BlzCreateFrameByType("FRAME", "FaceFrame", face,"", 0) --face is a BACKDROP it can not have events nor a tooltip, thats why one creates an empty frame managing that.
local tooltip = BlzCreateFrame("BoxedText", face, 0, 0)--Create the BoxedText Frame
--faceHover would be unneeded if face would support events/tooltip
BlzFrameSetAllPoints(faceHover, face) --faceHover copies the size and position of face.
BlzFrameSetTooltip(faceHover, tooltip) --when faceHover is hovered with the mouse frame tooltip becomes visible.
BlzFrameSetSize(face, 0.04, 0.04)
BlzFrameSetAbsPoint(face, FRAMEPOINT_CENTER, 0.4, 0.3)
BlzFrameSetAbsPoint(tooltip, FRAMEPOINT_CENTER, 0.2, 0.3)
BlzFrameSetSize(tooltip, 0.15, 0.08)
BlzFrameSetText(BlzGetFrameByName("BoxedTextValue",0), "Human Paladin Face, but it is not uther.")--BoxedText has a child showing the text, set that childs Text.
BlzFrameSetText(BlzGetFrameByName("BoxedTextTitle",0), "Paladin")--BoxedText has a child showing the Title-text, set that childs Text.
BlzFrameSetTexture(face, "ReplaceableTextures\\CommandButtons\\BTNHeroPaladin",0, true)--face uses paladin blp as texture.
end
-
Start
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Custom script: Face2()
-
-
That is nice, Text in a box, also similar to the default one.
Instead of creating such a BoxedText one could use a TEXTAREA. TEXTAREA does most of BoxedText, but it has a scrollbar blocking a part of the right side and it requires the box to have a min size (else it crashes the game / the thread). Also it becomes a bit tricky with the title.
ChangeLog: Added <UseActiveContext,> to the children in fdf. Without it, the tooltip text inside the box would work wrong for createcontext not be 0.
Other UI-Frame Tutorials
The following links might provide more insight into this subject.UI: Change Lumber Text
[JASS/AI] - UI: Create a TextButton
[JASS/AI] - UI: Positionate Frames (important)
UI: toc-Files
UI: Reading a FDF
UI - The concept of Parent-Frames
[JASS/AI] - UI: FrameEvents and FrameTypes
UI: Frames and Tooltips
[JASS/AI] - UI: Creating a Bar
UI - Simpleframes
UI: What are BACKDROPs?
UI: GLUEBUTTON
UI: TEXTAREA the scrolling Text Frame
UI: EditBox - Text Input
[JASS/AI] - UI: Creating a Cam control
UI: Showing 3 Multiboards
UI: OriginFrames
Default Names for BlzGetFrameByName (Access to Existing game-Frames)
[JASS/AI] - UI: List - Default MainFrames (built in CreateAble)
Attachments
Last edited: