A 'PopupList' control (implemented with OOP).

Share your advanced PureBasic knowledge/code with the community.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

:D
Dare2 cut down to size
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

Hi,

is there any chance to get it work with Gnozals PureColor?
The MenuItems disappears....

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;Demo of the OOP class for implementing PopupLists.

;By Stephen Rodriguez.

;Demonstrates some of the methods exposed by the 'PopupList' class.
;/////////////////////////////////////////////////////////////////////////////////

XIncludeFile "PopupList.pbi"

;Open a window upon which to place the PopupList control.
If OpenWindow(0, 0, 400, 270, 140, "PopupList class demo", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  If CreateMenu(0, WindowID(0))
    MenuTitle("File") 
    PureCOLOR_MenuItem(0, 1,"New"+Chr(9)+"Ctrl+N")
    PureCOLOR_MenuItem(0, 2,"&Open"+Chr(9)+"Ctrl+O")
  EndIf
;Create an instance of a PopupList control.
  MyPopupListObject.PopupListObject
  MyPopupListObject = NewPopupList(20,0,100,240)

;Add some items.
  For i = 0 To 5
    MyPopupListObject\AddItem(-1, "Item "+Str(i))
  Next

;Set some colors.
  MyPopupListObject\SetColor(#PB_Gadget_BackColor, RGB(252, 134, 0))

  Repeat
    eventID = WaitWindowEvent()
    Select eventID  
      Case #WM_RBUTTONDOWN
        MyPopupListObject\Resize(WindowMouseX(0), WindowMouseY(0), #PB_Ignore, #PB_Ignore)
        MyPopupListObject\Show()
        item = MyPopupListObject\GetState()
        Select item
          Case -1
            MessageRequester("PopupList", "Selection cancelled!")
          Default
            MessageRequester("PopupList", "Selected item "+Str(item))
        EndSelect
    EndSelect   
  Until eventID = #PB_Event_CloseWindow

;Destroy the PopupList object when no longer required.
  MyPopupListObject\Destroy()

EndIf
Best regards
Marco
PureBasic for Windows
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Ah, there can only be one reason for that!

Hang on...
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Marco, the PureColor problem should be fixed. I can't test because I don't use PureColor so if you wouldn't mind checking the latest update for me I would be grateful.

The download link is in the first post.
I may look like a mule, but I'm not a complete ass.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

YES!!

Thanx a lot!!


Fixed a problem without using PureColor... :shock:
PureBasic for Windows
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Marco2007 wrote:YES!!

Thanx a lot!!


Fixed a problem without using PureColor... :shock:
With the problem you described, the only possible cause was for my #WM_DRAWITEM handler to be swallowing such messages intended for other controls or ownerdrawn menus etc. Looking at my code, this was indeed what was happening!
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Update - Jan 1st 2008.
Bug fixed.

The PopupList control was destroying all other ownerdrawn controls placed on the same window! Doh! :oops:

Please see the first post for the download link.
I may look like a mule, but I'm not a complete ass.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I assume you already know that if you use the scroll wheel the selection isn't updated until you move the mouse?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I have no mousewheel, so no! :wink:

Then again, I'm just using a combobox gadget and haven't interfered with the scrolling or keyboard input at all, so I am guessing that what you are seeing is just normal combobox behaviour.

Would you mind trying it out on a normal combobox gadget Trond? See if you get the same behaviour?

Thanks.
I may look like a mule, but I'm not a complete ass.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Normal comboboxes don't have hot-tracking, so they can't have the same problem.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Right, just used my brother's computer which has a mousewheel. That is normal behaviour for a combobox Trond. The listbox scrolls but only highlights an item when you mouseover the item. The same is true for any combo even those without scrollbars.

I've compared the PopupList control with a normal combo and they both operate in an identical fashion as far as the scrollwheel is concerned.
I may look like a mule, but I'm not a complete ass.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Well, it's good in a sense as well, as it doesn't change things unnecessarily. (You should get a scroll wheel. When you're used to it, working without one feels like you're missing an arm.)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Aye, I do miss not having one I must admit. Then again I love this little thinkpad so much. The damn thing is stronger than Conan Powell!
I may look like a mule, but I'm not a complete ass.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

You can't get the side of the touchpad to be treated as a scrollbar?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Doesn't have one; it uses one of those fiddly finger buttony type scrollers.

http://images.google.co.uk/images?um=1& ... inkpad+x30
I may look like a mule, but I'm not a complete ass.
Post Reply