Hi all,
I am trying to write a small app for work, so it needs to be cross platform, so no MUI Royale.
I have a need for several text inputs from the user, and the popup string requester is looks very messy when included in the program.
Does anyone have a simple textbox example I can have a look at.
Thanks
Leo
Need help with Text Input box
Need help with Text Input box
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Re: Need help with Text Input box
Text Input box is very hard to make with Hollywood (or any other language that doesnt directly support the idea).
However, Allanon is working on HGUI, which will have Text Input boxes as one of the things:
http://forums.hollywood-mal.com/viewtop ... f=7&t=1032
But when is he finally going to make a release that we get to use it? Who knows.
Perhaps you can PM him and ask if he be so kind as to send you just the input box part to use.
However, Allanon is working on HGUI, which will have Text Input boxes as one of the things:
http://forums.hollywood-mal.com/viewtop ... f=7&t=1032
But when is he finally going to make a release that we get to use it? Who knows.
Perhaps you can PM him and ask if he be so kind as to send you just the input box part to use.
Re: Need help with Text Input box
Hi all,
Here is my first try at a String input gadet, it works but it could be a bit better.
I am sure it could be improved, I should be able to use the tables better.
Hope it helps someone else, if you improve it please post your improvements here.
Have fun.
Leo
Here is my first try at a String input gadet, it works but it could be a bit better.
Code: Select all
@VERSION 6,0
@APPTITLE "Gadgets"
@APPVERSION "$VER: 1.0 (04.07.15)"
@APPCOPYRIGHT "©2015, George Leo den Hollander"
@APPAUTHOR "Leo den Hollander"
@APPDESCRIPTION "Simple Gadgets"
@DISPLAY 1, {Width=400,Height=320,Color=#gray,Title=" Gadgets by Leo den Hollander"}
; Setup tables
GadgetText = {}
GadgetState = {}
GadgetFColor = {}
GadgetBColor = {}
GadgetFont = {}
GadgetFontSize = {}
; Setup Globals
global Gadget
global Gadgetx
global Gadgety
global Gadgetw
global Gadgeth
Function GadgetButton(ID,x,y,w,h,Text$,BC,FC)
SetFillStyle(#FILLGradient,#Linear,#Silver,RGB(64,64,64),12)
Box(x, y, w, h, #GRAY)
SetFillStyle(#FILLCOLOR)
Box(x+2, y+2, w-4, h-4, BC)
SetFont("DejaVu Sans",18)
TW = Textwidth(Text$)
t =(w/2)-(tw/2)
SetFontColor(FC)
Textout(x+t,y+3,Text$)
MakeButton(ID, #SIMPLEBUTTON, x+2, y+2, w-4, h-4, Events)
GadgetFColor[ID] = FC
GadgetBColor[ID] = BC
EndFunction
Function GadgetLabel(ID,x,y,w,h,Text$,BC,FC)
Setlinewidth(1)
SetFillStyle(#FILLGradient,#Linear,RGB(96,96,96),#Silver,27)
Box(x, y, w, h, #Gray)
SetFillStyle(#FILLCOLOR)
Box(x+2, y+2, w-4, h-4, BC)
Line(x+1, y+1, x+w-2, y+1, #Black)
Line(x+1, y+1, x+1, y+h-2, #Black)
Line(x+1, y+h-2, x+w-2, y+h-2, #White)
Line(x+w-2, y+1,x+w-2,y+h-2, #White)
SetFont("DejaVu Sans",18)
SetFontColor(FC)
Textout(x+4,y+3,Text$)
GadgetFColor[ID] = FC
GadgetBColor[ID] = BC
EndFunction
Function GadgetCheck(ID,x,y,Text$,BC,FC)
Setlinewidth(1)
SetFillStyle(#FILLGradient,#Linear,RGB(96,96,96),#Silver,27)
Box(x, y, 25,25, #Gray)
SetFillStyle(#FILLCOLOR)
Box(x+2, y+2, 21, 21, BC)
Line(x+1, y+1, x+23, y+1, #Black)
Line(x+1, y+1, x+1, y+23, #Black)
Line(x+1, y+23, x+23, y+23, #White)
Line(x+23, y+1,x+23,y+23, #White)
SetFont("DejaVu Sans",18)
SetFontColor(FC)
Textout(x+30,y+3,Text$)
MakeButton(ID, #SIMPLEBUTTON, x+2, y+2, 21, 21, Events)
GadgetState[ID] = 0
GadgetFColor[ID] = FC
GadgetBColor[ID] = BC
EndFunction
Function GadgetOption(ID,x,y,Text$,BC,FC)
Setformstyle(#ANTIALIAS)
SetFillStyle(#FILLGradient,#Linear,#white,#Black,45)
Circle(x,y,12,#White)
SetFillStyle(#FILLCOLOR)
Circle(x+2,y+2,10,#Silver)
SetFillStyle(#FILLNONE)
Setlinewidth(2)
Circle(x+4,y+4,8,#Gray)
Textout(x+30,y+3,Text$)
Setformstyle(#Normal)
MakeButton(ID, #SIMPLEBUTTON, x+2, y+2, 21, 21, options)
GadgetState[ID] = 0
GadgetFColor[ID] = FC
GadgetBColor[ID] = BC
EndFunction
Function GadgetString(ID,x,y,w,h,Text$,BC,FC)
Setlinewidth(1)
SetFillStyle(#FILLGradient,#Linear,RGB(96,96,96),#Silver,27)
Box(x, y, w, h, #Gray)
SetFillStyle(#FILLCOLOR)
Box(x+2, y+2, w-4, h-4, BC)
Line(x+1, y+1, x+w-2, y+1, #Black)
Line(x+1, y+1, x+1, y+h-2, #Black)
Line(x+1, y+h-2, x+w-2, y+h-2, #White)
Line(x+w-2, y+1,x+w-2,y+h-2, #White)
SetFont("DejaVu Sans",18)
GadgetFont[ID] = "DejaVu Sans"
GadgetFontSize[ID] = 18
SetFontColor(FC)
GadgetText[ID] = Text$
GadgetFColor[ID] = FC
GadgetBColor[ID] = BC
Textout(x+4,y+3,GadgetText[ID],GadgetFColor[ID])
MakeButton(ID, #SIMPLEBUTTON, x+2, y+2, w-4, h-4, Events)
EndFunction
Function GadgetButtonImage(ID,x,y,w,h,Text$)
SetFillStyle(#FILLGradient,#Linear,#Silver,RGB(64,64,64),12)
Box(x, y, w, h, #GRAY)
SetFillStyle(#FILLCOLOR)
Box(x+2, y+2, w-4, h-4,#Silver)
LoadBrush(ID,Text$)
DisplayBrush(ID,x+2, y+2, {width = w-4, height = h-4})
MakeButton(ID, #SIMPLEBUTTON, x+2, y+2, w-4, h-4, Events)
EndFunction
Function p_EventGad(msg)
Switch msg.action
Case "OnMouseDown":
Setlinewidth(1)
SetFillStyle(#FILLNONE)
Gadget = (msg.id)
Gadgetx = msg.x
Gadgety = msg.y
Gadgetw = msg.width
Gadgeth = msg.height
Box(msg.x, msg.y, msg.width, msg.height, #Teal)
p_SetCheck(Gadget)
Case "OnMouseOut":
Setlinewidth(1)
SetFillStyle(#FILLNONE)
Box(msg.x, msg.y, msg.width, msg.height, #Silver)
Case "OnMouseUp":
Setlinewidth(1)
SetFillStyle(#FILLNONE)
Box(msg.x, msg.y, msg.width, msg.height, #Silver)
Case "OnMouseOver":
Setlinewidth(1)
SetFillStyle(#FILLNONE)
Box(msg.x, msg.y, msg.width, msg.height,#Gray)
endswitch
EndFunction
Function p_StringText(msg)
Switch Gadget
Case 9
Key$ = (msg.key)
if (msg.key) = "BACKSPACE"
GadgetText[Gadget] = leftstr(GadgetText[Gadget],strlen(GadgetText[Gadget])-1)
elseif (msg.key) = "DEL"
GadgetText[Gadget] = ""
Key$ = ""
else
if TextWidth(GadgetText[Gadget]) < Gadgetw-10
GadgetText[Gadget] = GadgetText[Gadget] .. Key$
endif
endif
SetFillStyle(#FILLCOLOR)
SetFontColor(GadgetFColor[Gadget])
Box(Gadgetx+1, Gadgety+1,Gadgetw-2, Gadgeth-2, GadgetBColor[Gadget])
SetFont(GadgetFont[Gadget],GadgetFontSize[Gadget])
Textout(Gadgetx+2,Gadgety,GadgetText[Gadget])
Case 10
Key$ = (msg.key)
if (msg.key) = "BACKSPACE"
GadgetText[Gadget] = leftstr(GadgetText[Gadget],strlen(GadgetText[Gadget])-1)
elseif (msg.key) = "DEL"
GadgetText[Gadget] = ""
Key$ = ""
else
if TextWidth(GadgetText[Gadget]) < Gadgetw-10
GadgetText[Gadget] = GadgetText[Gadget] .. Key$
endif
endif
SetFillStyle(#FILLCOLOR)
SetFontColor(GadgetFColor[Gadget])
Box(Gadgetx+1, Gadgety+1,Gadgetw-2, Gadgeth-2, GadgetBColor[Gadget])
SetFont(GadgetFont[Gadget],GadgetFontSize[Gadget])
Textout(Gadgetx+2,Gadgety,GadgetText[Gadget])
Case 11
Key$ = (msg.key)
if (msg.key) = "BACKSPACE"
GadgetText[Gadget] = leftstr(GadgetText[Gadget],strlen(GadgetText[Gadget])-1)
elseif (msg.key) = "DEL"
GadgetText[Gadget] = ""
Key$ = ""
else
if TextWidth(GadgetText[Gadget]) < Gadgetw-10
GadgetText[Gadget] = GadgetText[Gadget] .. Key$
endif
endif
SetFillStyle(#FILLCOLOR)
SetFontColor(GadgetFColor[Gadget])
Box(Gadgetx+1, Gadgety+1,Gadgetw-2, Gadgeth-2, GadgetBColor[Gadget])
SetFont(GadgetFont[Gadget],GadgetFontSize[Gadget])
Textout(Gadgetx+2,Gadgety,GadgetText[Gadget])
Endswitch
EndFunction
Function p_Eventopt(msg)
Setformstyle(#ANTIALIAS)
Switch msg.action
Case "OnMouseOut":
Setlinewidth(2)
SetFillStyle(#FILLNONE)
Circle(msg.x+1,msg.y+1,8,#Gray)
Case "OnMouseOver":
Setlinewidth(2)
SetFillStyle(#FILLNONE)
Circle(msg.x+1,msg.y+1,8,#Silver)
Case "OnMouseDown":
Setlinewidth(2)
SetFillStyle(#FILLNONE)
Circle(msg.x+1,msg.y+1,8,#Teal)
Gadget = (msg.id)
Gadgetx = msg.x
Gadgety = msg.y
p_SetCheck(Gadget)
Case "OnMouseUp":
Setlinewidth(2)
SetFillStyle(#FILLNONE)
Circle(msg.x+1,msg.y+1,8,#Silver)
EndSwitch
Setformstyle(#Normal)
EndFunction
Function p_SetCheck(Gadget)
SetFontColor(#GREEN)
SetFillStyle(#FILLCOLOR)
Switch Gadget
Case 5
Box(Gadgetx+1, Gadgety+1,Gadgetw-2, Gadgeth-2, #Silver)
SetFont("DejaVu Sans Bold",20)
if GadgetState[Gadget] = 0
Textout(Gadgetx+4,Gadgety+1,"X")
GadgetState[Gadget] = 1
else
Textout(Gadgetx+4,Gadgety+1," ")
GadgetState[Gadget] = 0
endif
Case 6
Box(Gadgetx+1, Gadgety+1,Gadgetw-2, Gadgeth-2, #Silver)
SetFont("DejaVu Sans Bold",20)
if GadgetState[Gadget] = 0
Textout(Gadgetx+4,Gadgety+1,"X")
GadgetState[Gadget] = 1
else
Textout(Gadgetx+4,Gadgety+12," ")
GadgetState[Gadget] = 0
endif
Case 7
if GadgetState[Gadget] = 0
Circle(Gadgetx+4,Gadgety+4,6,#Green)
GadgetState[Gadget] = 1
else
Circle(Gadgetx+4,Gadgety+4,6,#Silver)
GadgetState[Gadget] = 0
endif
Case 8
if GadgetState[Gadget] = 0
Circle(Gadgetx+4,Gadgety+4,6,#Green)
GadgetState[Gadget] = 1
else
Circle(Gadgetx+4,Gadgety+4,6,#Silver)
GadgetState[Gadget] = 0
endif
EndSwitch
Endfunction
eventstring={OnKeyUp = p_StringText}
events = {OnMouseOver = p_EventGad, OnMouseOut = p_EventGad, OnMouseDown = p_EventGad, OnMouseUp = p_EventGad}
options = {OnMouseOver = p_Eventopt, OnMouseOut = p_Eventopt, OnMouseDown = p_Eventopt,OnMouseUp = p_Eventopt}
InstallEventHandler(eventstring)
; Escape ******************************************************************************************
EscapeQuit(True)
GadgetButton(1,20, 30,100,25,"Button",#Silver,#Black)
GadgetButton(2,20, 60,100,25,"Button",#Silver,#Black)
GadgetLabel(3,20, 90,100,25,"Label",#Silver,#Black)
GadgetLabel(4,20,120,100,25,"Label",#Silver,#Black)
GadgetCheck(5,20,150,"Check",#Silver,#Black)
GadgetCheck(6,20,180,"Check",#Silver,#Black)
GadgetOption(7,20,210,"Option",#Silver,#Blue)
GadgetOption(8,20,240,"Option",#Silver,#Blue)
GadgetString(9,20,270,100,25,"Test1",#silver,#Black)
GadgetString(10,150,30,220,25,"",#silver,#Black)
GadgetString(11,150,60,100,25,"",#silver,#Black)
GadgetButtonImage(12,150,120,220,170,"Test.jpg")
; Main Program Loop *******************************************************************************
Repeat
WaitEvent
ForEver
Hope it helps someone else, if you improve it please post your improvements here.
Have fun.
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Re: Need help with Text Input box
Thanks a lot, if alannon doesnt release his HGUI or if its hard to take just the text input part out of it, i might use this one instead.
Truly shows how difficult it is to make such a simple text input gadget when looking at how many lines of code it takes.
Truly shows how difficult it is to make such a simple text input gadget when looking at how many lines of code it takes.
Re: Need help with Text Input box
@Bugala,
Thanks for the comments, as you can see there is more than just a Sting input gadget.
This is my attempt at solving the problem, it should be easy to remove what you don't need.
I will clean it up a bit, add some comments and put it in the Code Snippits Area.
I find Hollywood is great and it can do a lot, but is missing working examples in the manual, I know this
would make the manual very large but it would be a great help when coming to grips with the syntax.
Now to finish the program I started for work.
@ all,
If you have solved a problem, I am sure there are other people out there that are having the same
issues. Just create a working example and put it in the Code Snippits area and help make Hollywood user base
grow.
Regards
Leo
Thanks for the comments, as you can see there is more than just a Sting input gadget.
This is my attempt at solving the problem, it should be easy to remove what you don't need.
I will clean it up a bit, add some comments and put it in the Code Snippits Area.
I find Hollywood is great and it can do a lot, but is missing working examples in the manual, I know this
would make the manual very large but it would be a great help when coming to grips with the syntax.
Now to finish the program I started for work.
@ all,
If you have solved a problem, I am sure there are other people out there that are having the same
issues. Just create a working example and put it in the Code Snippits area and help make Hollywood user base
grow.
Regards
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Re: Need help with Text Input box
Hi Bugala,Bugala wrote:Thanks a lot, if alannon doesnt release his HGUI or if its hard to take just the text input part out of it, i might use this one instead.
Truly shows how difficult it is to make such a simple text input gadget when looking at how many lines of code it takes.
actually I'm really busy (like all summers ) but if you or anyone is interested in a HGui snapshot just request it via PM and I can send a package with the current beta
----------------------------
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆