Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/Media/gui/scripts/IConsole.lua @ 5165

Last change on this file since 5165 was 5162, checked in by rgrieder, 16 years ago

added some gui stuff. Standard stuff from Ogre media repo plus a lua script file.

File size: 1.8 KB
Line 
1--- Event Handlers ---
2
3---------------------------------------------------------
4---     Event to handle when "Return" is hit in the edit box
5--- Input Window: Console/Frame/Input
6---------------------------------------------------------
7function handleEntryAccepted(args)
8        -- Get a pointer to the input editbox
9        local input = this:getWindow() 
10        -- Get a pointer to the output MLEditbox
11        local output = this:getWindow("Console/Frame/ConsoleText")
12       
13        -- Retrieve the Text from the edit box
14        local instr = input:getText()
15               
16        -- Set the Editbox text to an empty string to clear out the entry
17        input:setText("")
18       
19        -- set the text in the output box to its current text + the new text.
20        output:setText(string.format("%s%s",output:getText(),instr))
21       
22        --Done!
23end
24
25function update(args)
26   --Yatta! -- this is called every frame -- Put somthing interesting here!
27end
28
29--- End Event Handlers ---
30
31--- Entry Point ---
32local winMgr = CEGUI.WindowManager:getSingleton()
33
34--- Load the xml for the instanced window we want, specifying true
35--- indicates that we are making an instanced window and the system will
36--- autogenerate a prefix for us.
37local root = winMgr:loadWindowLayout("Console.wnd",true)
38
39--- Since we are just now creating this window, there is no 'this' pointer
40--- for us to use. Instead since now we want to set the events we will use
41--- the getChild function which will recursivly search from the given node down
42--- until it find the window... it will throw an exception.
43root:getChild("Console/Frame/Input"):subscribeEvent("TextAccepted",handleEntryAccepted)
44
45--- This event is the window update event, it is called every frame
46root:subscribeEvent("WindowUpdate",update)
47
48-- Add it to the default GUI sheet
49CEGUI.System:getSingleton():getGUISheet():addChildWindow(root)
50       
Note: See TracBrowser for help on using the repository browser.