1 | --- Event Handlers --- |
---|
2 | |
---|
3 | --------------------------------------------------------- |
---|
4 | --- Event to handle when "Return" is hit in the edit box |
---|
5 | --- Input Window: Console/Frame/Input |
---|
6 | --------------------------------------------------------- |
---|
7 | function 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! |
---|
23 | end |
---|
24 | |
---|
25 | function update(args) |
---|
26 | --Yatta! -- this is called every frame -- Put somthing interesting here! |
---|
27 | end |
---|
28 | |
---|
29 | --- End Event Handlers --- |
---|
30 | |
---|
31 | --- Entry Point --- |
---|
32 | local 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. |
---|
37 | local 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. |
---|
43 | root:getChild("Console/Frame/Input"):subscribeEvent("TextAccepted",handleEntryAccepted) |
---|
44 | |
---|
45 | --- This event is the window update event, it is called every frame |
---|
46 | root:subscribeEvent("WindowUpdate",update) |
---|
47 | |
---|
48 | -- Add it to the default GUI sheet |
---|
49 | CEGUI.System:getSingleton():getGUISheet():addChildWindow(root) |
---|
50 | |
---|