[Gambas-user] FileProperties.Data

T Lee Davidson t.lee.davidson at gmail.com
Mon Jul 9 18:55:24 CEST 2018


The FileProperties.Data property is a virtual object that is created by, and apparently only by, the FileProperties.Data() event
handler when the FileProperties.Path is set. If there is no FileProperties.Data() event handler in your code, the Data property
is unavailable.

The following FMain.class code is based on a FMain.form with a FileProperties control, a CheckBox, and a Button.

[code]
' Gambas class file

Public Sub Form_Open()

  CheckBox1.Value = True 'We start with default behaviour of the FileProperties dialog
  Button1_Click() 'Set FileProperties.Path

End


Public Sub Button1_Click()

  FileProperties1.Path = "/usr/share/icons/hicolor/64x64/apps/firefox.png"
  'With the Data Event commented, trying to access the Data property causes a "Data property unavailable" error
  Print "Data Type: " & FileProperties1.Data.Type

End

' Public Sub FileProperties1_Data()
'
'   Print "Entered Data Event"
'
'   If CheckBox1.Value = True Then 'We want default behaviour of the FileProperties dialog
'     Stop Event 'See http://gambaswiki.org/wiki/comp/gb.form/fileproperties/.data
'     Return 'So we do not set the Data properties
'   Endif
'
'   FileProperties1.Data.Type = "Custom Image"
'   FileProperties1.Data.Icon = Picture.Load("/usr/share/icons/hicolor/64x64/apps/firefox.png")
'
' End
[/code]

After uncommenting the FileProperties1_Data() event handler, you can uncheck the CheckBox and click the Button to see how the
behaviour changed. Also notice that the FileProperties.Data() event is raised every time FileProperties.Path is set.



-- 
Lee


On 07/08/2018 01:33 PM, Hans Lehmann wrote:
> Hello.
> 
> I have great difficulty understanding how the FileProperties.Data property interacts with the FileProperties.Data() event. Can
> anyone try to bring light into the darkness with an example or with appropriate source code?
> 
> With kind regards
> 
> Hans
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----



More information about the User mailing list