Page 1 of 1

[Resolved] Editable ComboBox Drag/Drop

Posted: Mon Jul 01, 2024 2:11 pm
by Kwai chang caine
Hello at all :D

I search to drag and drop in an editable ComboBoxGadget
I have trying several things without succès :oops:
If someone have an idea :wink:

Code: Select all

OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ComboBoxGadget(0, 10, 10, 250, 21, #PB_ComboBox_Editable)
ComboBoxGadget(1, 10, 50, 250, 21, #PB_ComboBox_Editable)

EnableGadgetDrop(0, #PB_Drop_Files, #PB_Drag_Copy) 
EnableGadgetDrop(1, #PB_Drop_Files, #PB_Drag_Copy) 

Repeat  
 
 Evenement = WaitWindowEvent()

If Evenement = #PB_Event_GadgetDrop
   
 PhraseFichier$ = EventDropFiles()
 WindowFromPoint_(Coord)
 GetCursorPos_(@point.POINT) 
 Handle = WindowFromPoint_(Point\X | (Point\Y << 32))
 PbIdGadget = GetDlgCtrlID_(Handle) 
 
 ; SetGadgetText(PbIdGadget, PhraseFichier$)                                         ; Not work
 ; SetGadgetText(GetWindow_(Handle, #GW_CHILD), PhraseFichier$)                      ; Not work
 ; SetGadgetText(GetWindow_(GadgetID(PbIdGadget), #GW_CHILD), PhraseFichier$)        ; Not work
   
EndIf
 
Until Evenement = #PB_Event_CloseWindow
Have a good day

Re: Editable ComboBox Drag/Drop

Posted: Mon Jul 01, 2024 2:32 pm
by firace
Hi KCC, hope you are doing well!

Something like this?

Code: Select all

OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ComboBoxGadget(0, 10, 10, 250, 21, #PB_ComboBox_Editable)
ComboBoxGadget(1, 10, 50, 250, 21, #PB_ComboBox_Editable)

EnableGadgetDrop(0, #PB_Drop_Files, #PB_Drag_Copy) 
EnableGadgetDrop(1, #PB_Drop_Files, #PB_Drag_Copy) 

Repeat  
  Evenement = WaitWindowEvent()
  
  If Evenement = #PB_Event_GadgetDrop
    
    PhraseFichier$ = EventDropFiles()
    
    SetGadgetText(EventGadget(), PhraseFichier$)      
    
  EndIf
Until Evenement = #PB_Event_CloseWindow

Re: Editable ComboBox Drag/Drop

Posted: Mon Jul 01, 2024 2:40 pm
by Axolotl
do it like this...

Code: Select all

OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ComboBoxGadget(0, 10, 10, 250, 21, #PB_ComboBox_Editable)
ComboBoxGadget(1, 10, 50, 250, 21, #PB_ComboBox_Editable)

EnableGadgetDrop(0, #PB_Drop_Files, #PB_Drag_Copy) 
EnableGadgetDrop(1, #PB_Drop_Files, #PB_Drag_Copy) 

Repeat  
 
 Evenement = WaitWindowEvent()

If Evenement = #PB_Event_GadgetDrop
   
  PhraseFichier$ = EventDropFiles()
;  WindowFromPoint_(Coord)
;  GetCursorPos_(@point.POINT) 
;  Handle = WindowFromPoint_(Point\X | (Point\Y << 32))
;  PbIdGadget = GetDlgCtrlID_(Handle) 

  Select EventGadget() 
    Case 0, 1   ; my comboboxes :) 
      If PhraseFichier$ 
        AddGadgetItem(EventGadget(), -1, PhraseFichier$) 
        SetGadgetText(EventGadget(), PhraseFichier$) 
      EndIf 
 
  EndSelect 

 ; SetGadgetText(PbIdGadget, PhraseFichier$)                                         ; Not work
 ; SetGadgetText(GetWindow_(Handle, #GW_CHILD), PhraseFichier$)                      ; Not work
 ; SetGadgetText(GetWindow_(GadgetID(PbIdGadget), #GW_CHILD), PhraseFichier$)        ; Not work
   
EndIf
 
Until Evenement = #PB_Event_CloseWindow


Re: Editable ComboBox Drag/Drop

Posted: Mon Jul 01, 2024 2:41 pm
by Axolotl
the second is the first loser..... :oops:

Re: Editable ComboBox Drag/Drop

Posted: Mon Jul 01, 2024 4:02 pm
by Kwai chang caine
Hello at you two

I have searched a long time and sometimes.... we go looking far away, for what is very close :oops:
And it's always easy to say : "That it was so simple !!!", when you are given to me the solution :mrgreen: :oops:

Thanks a lot for your quick and precious help 8)
Axolotl wrote:the second is the first loser...
:lol:
Furthermore, i have win a nice proverb (Apparently of Ayrton Senna), that I did not know 8)
I note it preciously...in my long collection of nice proverbs :wink:

Have a very end of day my friends 8)