Documentation of data types and MakeButton()

Report any Hollywood bugs here
Post Reply
nexus
Posts: 150
Joined: Sun Mar 07, 2010 11:54 am

Documentation of data types and MakeButton()

Post by nexus »

Documentation of MakeButton()
https://www.hollywood-mal.com/docs/html ... utton.html
says:
ID:
Contains the identifier of the button that triggered this event. This field is a number.
But at least on my side with a button of Type #LAYERBUTTON, the `ID` is of type
`#LIGHTUSERDATA`

Hence, I cannot find the actual button's ID in the message table (only the associated layer name).

Moreover, the documentation is lacking infos about the data types #USERDATA, #LIGHTUSERDATA and #THREAD:

https://www.hollywood-mal.com/docs/html ... Intro.html

So, what can I do with those data types? :)

Hier is a print out of all properties and types provided in the received message table of a button of type `#LAYERBUTTON` with HW10:

Code: Select all

MakeButton(Nil,#LAYERBUTTON, "LoadButton", { OnMouseDown = p_LoadButtonHandler } )

Function p_LoadButtonHandler(event)
  DebugPrint("LoadButtonHandler called!")
  p_DebugPrintTable(event, "----- event on loadbutton ----")
EndFunction

Function p_DebugPrintTable(table, msg)

  If msg <> Nil Then DebugPrint(msg)

  For k,v In Pairs(table)
    If GetType(v) = #TABLE
      p_DebugPrintTable(v,"Table ",k,":")
    ElseIf GetType(v) = #LIGHTUSERDATA
      DebugPrint(k,"=",v,"("..typeMap[GetType(v)]..")", "ToNumber:" ,ToNumber(v))
    Else
      DebugPrint(k,"=",v,"("..typeMap[GetType(v)]..")")
    EndIf
  Next

EndFunction
Results in:
LoadButton pressed!
----- event on loadbutton ----
action = OnMouseDown (#STRING)
layername = LoadButton (#STRING)
id = UserData: 0000000008CAC590 (#LIGHTUSERDATA) ToNumber: 147506576
layer = 11 (#NUMBER)
midmousedown = 0 (#NUMBER)
width = 0 (#NUMBER)
y = 0 (#NUMBER)
x = 0 (#NUMBER)
display = 1 (#NUMBER)
height = 0 (#NUMBER)
timestamp = 5.4103851318359 (#NUMBER)
rightmousedown = 0 (#NUMBER)
mousedown = 1 (#NUMBER)
Thanks,
Tom
User avatar
jPV
Posts: 674
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Documentation of data types and MakeButton()

Post by jPV »

When you use automatic ID selection, you dont get IDs as numbers but something that is in the #LIGHTUSERDATA type, which isn't meant to be human readable. There's no need to interpret such data yourself, just use contents for IDs as it is. If you want to use IDs with numbers, use the manual ID numbering.

Here's documentation for it:
https://www.hollywood-mal.com/docs/html ... lect_.html
User avatar
airsoftsoftwair
Posts: 5615
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Documentation of data types and MakeButton()

Post by airsoftsoftwair »

nexus wrote: Sun Jun 16, 2024 12:13 pm Moreover, the documentation is lacking infos about the data types #USERDATA, #LIGHTUSERDATA and #THREAD:
True, I'll add some info about those types.
nexus
Posts: 150
Joined: Sun Mar 07, 2010 11:54 am

Re: Documentation of data types and MakeButton()

Post by nexus »

jPV wrote: Mon Jun 17, 2024 8:24 am When you use automatic ID selection, you dont get IDs as numbers but something that is in the #LIGHTUSERDATA type, which isn't meant to be human readable. There's no need to interpret such data yourself, just use contents for IDs as it is. If you want to use IDs with numbers, use the manual ID numbering.

Here's documentation for it:
https://www.hollywood-mal.com/docs/html ... lect_.html
Thanks! Means, just the MakeButton() docu is misleading as it says the "field is a Number".
And thanks for the hint in the docu. Makes sense now.

Tom.
User avatar
airsoftsoftwair
Posts: 5615
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Documentation of data types and MakeButton()

Post by airsoftsoftwair »

Code: Select all

- Fix [Doc]: The Hollywood manual didn't contain a description of the light userdata type that is used to
  store handles allocated by object constructors
Post Reply