PB3.20 - ComboBoxGadget() Event !?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Hi @ all
I use a ComboBoxGadget() and 12 different AddGadgetItem()... When i press with the mouse on the ComboBox, it will return a event; OK! But when i select any GadgetItem in this ComboBox i need to get a event too... I dont need GetGadgetState() for that... Is there any way?

Hope you understand my problem...!? Any idea how to solve this? Many thanks in advance...


PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...

greetz
MrVainSCL! aka Thorsten
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

Hi,

I posted a snippet in the 'Tips'n'tricks' section some time ago to solve that problem. I thought this had been fixed in some PB release, but it seems I'm wrong. In the meanwhile, I suggest you to take a look at the thread:

viewtopic.php?t=872 item selection in ComboBox gadgets&Forum_Title=Tricks %27n%27 Tips

Bye,

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

You have to do it with EventType like:

Code: Select all

;
;...
Case ComboBoxGadget#
  Select EventType()
    Case #PB_EventType_RightClick
      ;do something
  EndSelect
;....
don't know why, but for now (version 3.2) the event you need has the #PB_EventType_RightClick constant number.

This works for me, and I hope for you too...


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

True, I forgot to update that. Thanks

Updated but... #PB_EventRightClick doesn't get fired ¿? Switched back to #WM_CONTEXTMENU until I/Fred fix this.

El_Choni

Edited by - El_Choni on 02 July 2002 18:37:38
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Hmm, I thought #PB_EventType_ReturnKey is the one that Fred wants to remove.

#PB_EventType_RightClick works, till now... (I use it for my PureBasic wrapper)


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

I couldn't make it work with ComboBoxGadget. Could you please post a little snippet to find out what am I doing wrong?

Thanks. Bye,

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Sure

Code: Select all

; (c) 2002 - Franco's template - absolutely freeware
; Little example for the right use of the ComboBox Event
;

OpenWindow(1,200, 200, 320,240,#PB_Window_SystemMenu|#PB_Window_SizeGadget,"Window")
CreateGadgetList(WindowID())
 
CreateMenu(1, WindowID())
  MenuTitle("File")
    MenuItem(1,"New")
    MenuItem(2,"Open")
    MenuItem(3,"Save")
 
CreateToolBar(1, WindowID())
  ToolBarStandardButton(4,#PB_ToolBarIcon_New)
  ToolBarStandardButton(5,#PB_ToolBarIcon_Open)
  ToolBarStandardButton(6,#PB_ToolBarIcon_Save)
 
ButtonGadget(1, 10, 30, 100, 25,"Button 1")
 
ComboBoxGadget(2, 10, 120, 100, 250)
  AddGadgetItem(2, -1, "ComboBox Item 1") 
  AddGadgetItem(2, -1, "ComboBox Item 2") 
  AddGadgetItem(2, -1, "ComboBox Item 3") 
  AddGadgetItem(2, -1, "ComboBox Item 4") 
 
  Repeat
    EventID = WaitWindowEvent()
 
    Select EventID
      ; Menu/ToolBarEvent
      Case #PB_EventMenu
        MessageRequester("Menu or Toolbar","Item #: "+Str(EventGadgetID()),0)
 
      ; GadgetsEvents
      Case #PB_EventGadget
 
        Select EventGadgetID()
 
          ; ButtonGadget
          Case 1
            Select EventType()
              Case #PB_EventType_LeftClick
                MessageRequester("Gadget","Button",0)
            EndSelect
 
          ; ComboBoxGadget
          Case 2
            Select EventType()
              Case #PB_EventType_RightClick
                MessageRequester("Gadget","ComboBox",0)
            EndSelect
 
        EndSelect
 
    EndSelect
 
  Until EventID = #PB_EventCloseWindow
 
End
 

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

Hi,

Right-clicking does nothing. Left-clicking fires the #PB_EventType_RightClick event.

Using Windows XP (didn't work with Win 98 either), with all the updated libraries. What's happening here?

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

As I mentioned before:
don't know why, but for now (version 3.2) the event you need has the #PB_EventType_RightClick constant number.

This works for me, and I hope for you too...
the EventType results in a RightClick event, but actually you are pressing ONLY THE LEFT MOUSE BUTTON TWICE when you are choosing an item.

One left click and your combobox item window opens with 4 items.
Second left click and you choose an item.
Now you get an event (a #PB_EventType_RightClick event - don't ask me why!).

And like I said you will get this event although you NEVER press the Right Mouse Button.
Sorry if I wasn't clear enough the first time.
Hope I am now.

My example works/tested on Win98SE and WinXP.


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

Ok, I misunderstood your snippet. So #PB_EventType_RightClick can be used to catch item selection. Well, that's great.

Thanks,

El_Choni
Post Reply