Page 1 of 1

Documentation of data types and MakeButton()

Posted: Sun Jun 16, 2024 12:13 pm
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

Re: Documentation of data types and MakeButton()

Posted: Mon Jun 17, 2024 8:24 am
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

Re: Documentation of data types and MakeButton()

Posted: Mon Jun 17, 2024 9:40 pm
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.

Re: Documentation of data types and MakeButton()

Posted: Thu Jun 20, 2024 3:59 pm
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.

Re: Documentation of data types and MakeButton()

Posted: Sun Jul 21, 2024 10:20 pm
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