[Resolved] Editable ComboBox Drag/Drop

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5500
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

[Resolved] Editable ComboBox Drag/Drop

Post 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
Last edited by Kwai chang caine on Mon Jul 01, 2024 4:04 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
firace
Addict
Addict
Posts: 947
Joined: Wed Nov 09, 2011 8:58 am

Re: Editable ComboBox Drag/Drop

Post 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
Axolotl
Addict
Addict
Posts: 873
Joined: Wed Dec 31, 2008 3:36 pm

Re: Editable ComboBox Drag/Drop

Post 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

Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Axolotl
Addict
Addict
Posts: 873
Joined: Wed Dec 31, 2008 3:36 pm

Re: Editable ComboBox Drag/Drop

Post by Axolotl »

the second is the first loser..... :oops:
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5500
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Editable ComboBox Drag/Drop

Post 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)
ImageThe happiness is a road...
Not a destination
Post Reply