How to properly use parts of HGui in a hollywood program?
Posted: Sat Mar 28, 2026 10:09 pm
I am trying to use HGui to create a edit textbox within my program.
I can get it to work, but it will only work once per session.
What happens is that I start the program with a regular hollywood display, then I open the textbox and can edit the text as I need, then save and close the textbox and return back to the program.
Well, almost as easy as that.
When HGui open the textbox, it seem to take over my display 1. In order to return to my program I must first create a temporary second display, then I can close display 1 in order to re-create it and open it. That was the only method I found that made me able to reopen display 1.
Perhaps I have over-complicated this, and there is a more natural way to do it?
At this point the textbox is gone and I have the same display as when I started. But if trying to open the textbox again, there will be an error.
It seems that I have not managed to get rid of the remains of the textbox window.
I tried to free or close the HGui textbox window by using one of these lines, by using either will just kill the whole program.
I made an example script to demonstrate the issue
I can get it to work, but it will only work once per session.
What happens is that I start the program with a regular hollywood display, then I open the textbox and can edit the text as I need, then save and close the textbox and return back to the program.
Well, almost as easy as that.
When HGui open the textbox, it seem to take over my display 1. In order to return to my program I must first create a temporary second display, then I can close display 1 in order to re-create it and open it. That was the only method I found that made me able to reopen display 1.
Perhaps I have over-complicated this, and there is a more natural way to do it?
At this point the textbox is gone and I have the same display as when I started. But if trying to open the textbox again, there will be an error.
Code: Select all
Error in line 4113 (HGui.hws): Table newwin{} not found!I tried to free or close the HGui textbox window by using one of these lines, by using either will just kill the whole program.
Code: Select all
Gadget.Result.Window:free()
Gadget.Result.Window:close()Code: Select all
@DISPLAY {Title = "HGUI test", Width = 800, Height = 600}
@INCLUDE "C:/Program Files/Hollywood/HGui-main/+Includes.hws"
@INCLUDE #INC_HGUI
BeginDoubleBuffer()
SetFillStyle(#FILLCOLOR)
Function p_displaysomething()
xpos = Rnd(750)+1
ypos = Rnd(580)+1
xsize = Rnd(400)+1
ysize = Rnd(300)+1
Box(xpos, ypos, xsize, ysize, GetRandomColor())
SetFont(#SERIF, 24)
TextOut(550, 20, "CLICK HERE TO TEST")
Flip
EndFunction
Function p_HandlerFunc(msg)
Switch(msg.Action)
Case "OnMouseDown":
xpos = MouseX()
ypos = MouseY()
If xpos > 600 And ypos < 100
p_inputbox
EndIf
Case "CloseWindow":
Wait(50)
End
EndSwitch
EndFunction
Function p_inputbox()
EndDoubleBuffer()
ClearInterval(1)
If Exists("test.txt")
OpenFile(1, "test.txt")
While Not Eof(1)
string$ = string$.."\n"..ReadLine(1)
Wend
CloseFile(1)
string$ = StripStr(string$)
Else
string$ = "Edit this"
EndIf
myWin = HGui.Window:InputBoxNew(
{ text = string$,
ok = "Ok",
cancel = { "Cancel" },
callbackOk = p_callback,
callbackCancel = p_callback,
;callbackClose = p_callback,
;--- some standard window's tags ---
size = { w = 600, h = 300 },
title = "The HGui Input Box...",
name = "inputBox1"
})
If HGui.windowExists("inputBox1")
myWin:Set({ title = "Textbox"}, True)
EndIf
EndFunction
Function p_callback(Gadget)
If gadget.Result.Cancel
SystemRequest("Cancelled", "You pressed Cancel!", "OK")
Else
SystemRequest("Text saved to file", "Saved to file:\n"..Gadget.Result.text, "OK")
StringToFile(Gadget.Result.text, "test.txt")
EndIf
;create a temporay display to be able to close and recreate display 1
CreateDisplay(2, {width = 200, height = 100, HideTitleBar = True, Borderless = True})
OpenDisplay(2)
CloseDisplay(1)
CreateDisplay(1, {Title = "HGUI second test", Width = 800, Height = 600})
OpenDisplay(1)
CloseDisplay(2)
BeginDoubleBuffer
Flip
Box(0, 0, 1366, 768, #SILVER); Background
Flip
SetInterval(1, p_displaysomething, 100)
InstallEventHandler({ OnMouseDown = p_HandlerFunc, CloseWindow = p_HandlerFunc})
;using either of these commands will kill the program:
;Gadget.Result.Window:free()
;Gadget.Result.Window:close()
EndFunction
InstallEventHandler({ OnMouseDown = p_HandlerFunc, OnCloseWindow = p_HandlerFunc })
SetInterval(1, p_displaysomething, 100)
Repeat
WaitEvent()
Forever