Catch MOUSEEVENT on ListView?

BlitzMax Forums/BlitzMax Programming/Catch MOUSEEVENT on ListView?

MrCredo(Posted 2006) [#1]
hi,

can someone help me? How can i get a event, when i hit mousebutton in a ListView-Item. i need something to get TRUE, when i hit RIGHT mousebutton...


MrCredo(Posted 2006) [#2]
*push*


Hummelpups(Posted 2006) [#3]
Hm, i didn't got it with events. I used a canvas
under the listboxitem. It's a very
baaaad codestil. I tested it under Win, it works!
Don't know whether that is platformindependent.

Look at this code german fellow. ;)

window=CreateWindow("asd",10,10,400,400)

canvas=CreateCanvas(0,0,400,300,window)
listbox=CreateListBox(0,0,400,300,window)
AddGadgetItem listbox,"asd"
AddGadgetItem listbox,"asd2"
AddGadgetItem listbox,"asd3"

'HideGadget canvas
'ActivateGadget canvas

While WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
End

Case EVENT_MOUSEDOWN
Select EventData()
Case 1
SelectGadgetItem listbox,Rand(0,2)
'RedrawGadget listbox
'RedrawGadget canvas
'Notify("MT2")
End Select

End Select

Wend


IMurDOOM


MrCredo(Posted 2006) [#4]
hm... :-/

ok i check this also with panels later - panels are more resources-friendly


MrCredo(Posted 2006) [#5]
hmmm it tested it... panel work at the same way... but

panel or canvas eat all events - i can't select a list gadget with mouse... that is bad... what i need is only a mousebutton-event on treelist

:-/


klepto2(Posted 2006) [#6]
If you want to catch the MouseEvents on a tree or listview here is a small workaround for Win32(BTW: This should be in Max for every Gadget)

First you have to find the "win32listbox.cpp" in "mod\brl.mod\win32maxgui.mod\win32gui" and open it.

The First Function in this code related to the listbox is

Win32ListBox::Win32ListBox( BBGroup *group,int style ):BBListBox(group,style){
... a few things
...
_gadget.setWndProc(this);
}


Now to add the MouseEvents to the Listbox you simply have to
add one line, so it looks as follows:

Win32ListBox::Win32ListBox( BBGroup *group,int style ):BBListBox(group,style){
... a few things
...
_gadget.setWndProc(this);
_gadget.setEventMask( BBEVENT_MOUSEMASK,this );
}


And now you also catch the MouseEvents in a ListBox (completely with the x and y coordinates)

Only tested with listboxes, but should work also with every other Gadget.

BTW:
By changing :
setEventMask( BBEVENT_MOUSEMASK,this );
to
setEventMask( BBEVENT_MOUSEMASK|BBEVENT_KEYMASK,this );
You can also catch the keys pressed in the listbox

I hope this solves your problems


MrCredo(Posted 2006) [#7]
oh hell...

i think, mark should add this to all gadgets... i don't like to modify cpp code at each update...