Drag&Drop into TBGL-Window
issueid=395 19-04-2013 12:18
thinBasic MVPs
Number of reported issues by ReneMiner: 86
Drag&Drop into TBGL-Window

Reminder:

It would be great to have some possibility to detect if something from OS (as Filename from Win-Explorer/Icon from Desktop) was dragged and dropped into TBGL-Window without need to use UI nor Callbacks.
Should give information of Path\Filename, (possibly kind of dropped object if it's not a filename - but currently I have no idea what other objects would make sense here...)

see this Thread


Edit: But today I have already an additional "sense" in mind - but that would mean to go into the other direction too. So I might set Data to something (depends what user drags from where out of my current TBGL-Window) and drop this Data-Something into another currently running TBGL-apps-Window and the other window receives my User-data-something... Maybe OS-Clipboard could be "abused" here just MKx$(fromOurData) -> as "Text" to clipbaord and back. Would allow a couple of nice functionalities as visually arranging scenes and playgrounds very comfy - draw your mesh in editor and instantly drag it from there into the scene to test it - without the need of save here, open there etc. Enables different TBGL-apps to "communicate" and exchange data in a straightforward way and offers a "very modular+ extreme private scope" solution if more than one TBGL-Window is needed
And also - as already in the first part, just pull the Meshes-Name from Explorer into the scene...whoops there it is... :)
Issue Details
Issue Number 395
Issue Type Feature
Project TBGL
Category Unknown
Status Implemented
Priority Unknown
Suggested Version Unknown
Implemented Version (none)
Votes for this feature 1
Votes against this feature 0
Assigned Users (none)
Tags (none)




28-04-2013 10:55
Super Moderator
Hi Rene,

next release of thinBASIC will contain support for detection of user dropping files on the TBGL Window, here little example on how it works:
' -- The following enables programmer to handle dropping files to window
' -- The window is identified via hWnd handle
' -- Once the event occurs, the function Main_OnDropFiles will be launched
TBGL_BindWindowEvent(hWnd, %TBGL_OnDropFiles, Main_OnDropFiles)

...

' -- Function fired thanks to previous bind using TBGL_BindWindowEvent
Function Main_OnDropFiles()
  
  ' -- Retrieve number of files
  Long nFiles = TBGL_OnDropFiles_GetFileCount()
  Long i

  ' -- Iterate through all of them and list their names
  For i = 1 To nFiles
    MsgBox TBGL_CallingWindow, "File " + Format$(i) + " is " + TBGL_OnDropFiles_GetFileName(i)
  Next

End Function
Petr

28-04-2013 11:02
Super Moderator
If you want to test it right now, please feel free to download the latest TBGL here:
http://www.thinbasic.com/community/s...t-TBGL-version

Petr

28-04-2013 15:16
thinBasic MVPs
I instantly tried out - but there's some problem - I have no value to equate(?) %TBGL_OnDragFiles - even after creating new syntax\keywords-ini it is not bold. All other new keywords are bold- so I replaced with %TBGL_OnDropFiles - and what should I say: It works ! :D Great!

28-04-2013 15:46
Super Moderator
Hi Rene,

it was a typo, of course it should be %TBGL_OnDropFiles, oops :)
I corrected it in the help files and reuploaded.


Petr

28-04-2013 22:14

29-04-2013 08:16
thinBasic MVPs
One quick reply to this: TBGL-Help-Topic, TBGL_UnBindWindowEvent,

Syntax


TBGL_UnBindWindowEvent( hWnd, eventCode, eventHandler )

Why "eventHandler" here? Does not work if I use this.

Probably make a note to unbind before destroying TBGL-Window-
I had some "does not respond any more"-crash once this morning when I tried to end my script. It ran 10 times without crash before - so this does not happen always.
Probably caused by not unbinding before - crash did not repeat yet since I'm using unbind now... but maybe that changes during the day...
Can also be caused by combination of TBGL_BindWindowEvent & TBGL_PeriodicBindFunction- i dunno

29-04-2013 09:50
Super Moderator
Hi Rene,

thanks for the feedback, I corrected it in the help file. TBGL_UnBindWindowEvent really takes just two parameters. You can redownload here:
http://www.thinbasic.com/community/s...t-TBGL-version

Programmer does not need to unbind it before destroying window - it is made automatically. It is optional.

I use this code for tests and no crashes were observed so far (thinBasic 1.9.6.0 Eros prepaired + latest TBGL patch from this morning):
'
' Test for dropping files
'

Uses "TBGL" 

Function TBMain()
  Local hWnd      As DWord
  Local FrameRate As Double
  
  ' -- Create and show window
  hWnd = TBGL_CreateWindowEx("TBGL file dropping test - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) 
  TBGL_ShowWindow 
  
  
  ' -- Initialize lighting
  TBGL_UseLighting(%TRUE)
  TBGL_UseLightSource(%GL_LIGHT0, %TRUE)
  TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 15, 10, 15, 1)

  ' -- Resets status of all keys 
  TBGL_ResetKeyState()
  
  ' -- Bind event handler
  TBGL_BindWindowEvent(hWnd, %TBGL_OnDropFiles, Main_OnDropFiles)
    
  ' -- Main loop
  While TBGL_IsWindow(hWnd) 
    FrameRate = TBGL_GetFrameRate

    TBGL_ClearFrame 
      TBGL_Camera(15, 15, 15, 0, 0, 0)
      
      TBGL_Color(255, 128, 0)
      TBGL_Box(1, 1, 1)

    TBGL_DrawFrame 

    ' -- ESCAPE key to exit application
    If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While 

  Wend 
  
  ' -- Optional
  TBGL_UnBindWindowEvent(hWnd, %TBGL_OnDropFiles)
  TBGL_DestroyWindow
End Function 

' -- Function fired thanks to previous bind using TBGL_BindWindowEvent
Function Main_OnDropFiles()
  
  ' -- Retrieve number of files
  Long nFiles = TBGL_OnDropFiles_GetFileCount()
  Long i

  ' -- Iterate through all of them and list their names
  For i = 1 To nFiles
    MsgBox TBGL_CallingWindow, "File #" + Format$(i) + " is " + TBGL_OnDropFiles_GetFileName(i)
  Next

End Function
Petr

+ Reply