1. RE: ListView SINGLE-click detection
- Posted by Andy Drummond <kestrelandy at xalt.co.uk> Oct 19, 2001
- 416 views
Dan The idea is this: there seems to be no sensible event for a single click on a ListView. So I put a procedure in the listview onEvent[] list, and then every message for the listview gets to that procedure. There I look for what's needed, in this case a WM_PAINT when the item clicked on is re-painted with a highlight bar. I distinguish this from unhighlighting by seeing if this item is one I have already handled. So if it's a new item, I first remember which one it is so I don't do the works again, then I go do whatever I want on this single click. My routine is actually ShowSelected() which I use to show the details of the listview item I clicked on. That way I can click on items in a listview and as I do show the details in another window ... and it seems to work just dandy! It also seems very simple to implement with no problems.... just thought it might solve your problem ... Andy Dan Moyer wrote: > Andy, > > I *think* I can follow what you're doing, in your specific example, but > not > sure exactly what you mean by your general method of trapping every > message, > and it sounds useful! > > Here's approximately what Euman suggested, which *works* for single > click > detection: > > -- first make an extended style listview > global constant ListView2 = createEx( ListView, {}, Window1, 12, 16,680, > 132,or_all({LVS_REPORT,LVS_SINGLESEL}), or_all({LVS_EX_FULLROWSELECT, > LVS_EX_ONECLICKACTIVATE})) > > -- but since (apparently) the extended styles don't get properly set(?), > re-set them: > object junk > atom lvMask > -- makes full row selected, hand pointer moving on listview items > selects > them, > -- single click is responded to: > lvMask = or_all({LVS_EX_FULLROWSELECT,LVS_EX_TRACKSELECT , > LVS_EX_ONECLICKACTIVATE }) > > -- hovertime makes selection happen as quick as can move mouse: > junk = sendMessage( ListView2, LVM_SETHOVERTIME, 0, 1)-- 1=quick select > junk = sendMessage( ListView2, LVM_SETEXTENDEDLISTVIEWSTYLE, lvMask, > lvMask) > > -- & then in an onMouse event: > if event = WM_LBUTTONDOWN then > if getLVCount(ListView2) then > index = getLVSelected(ListView2) > if length(index) then > > > Dan > > > ----- Original Message ----- > From: "Andy Drummond" <kestrelandy at xalt.co.uk> > To: "EUforum" <EUforum at topica.com> > Sent: Friday, October 19, 2001 5:51 AM > Subject: ListView SINGLE-click detection > > > > Dan et al, > > Reading back I just saw that the problem is in SINGLE-click > > detecting, not double click. So try this ... > > > > What I do is trap EVERY message in a trace(1) and see what sequence > > is likly to do what I want. this works fine for me, so it should > > for you to. > > > > > > atom LastLVpos -- Initialise to something, like -1 > > > > procedure ListView_onEvent ( int iMsg, atom wParm, atom lParm ) > > seq LVpos > > > > if iMsg = WM_PAINT then > > LVpos = getLVSelected(ListView) > > > > if length(LVpos) and LVpos[1] != LastLVpos then > > LastLVpos = LVpos[1] > > ShowSelected() > > end if > > end if > > end procedure > > > > > > Good luck, Andy > > > >
2. RE: ListView SINGLE-click detection
- Posted by Andy Drummond <kestrelandy at xalt.co.uk> Oct 20, 2001
- 388 views
Dan, My apologies in return. What I did was put an onEvent() procedure in my program for the control I was interested in, and add a trace(1). Then every message for that control got trapped and I could see on the Euphoria debug screen what messages I was getting. I write them down and see what they all are. Probably better to simply declare a static sequence and add them into it for every message, then grab it later and see what messages I got. Sometimes it is very revealing, but usually it is totally confusing, Windows being what it is. Maybe I should write a module to convert the message into a list of WM_WHATEVER's to make it easier to see what is going on. It's a pretty basic method, but as I don't understand Windows most of the time - which is why I use Euphoria + Win32Lib + IDE to make code for it. So when I get a situation like that I have to simply see what Windows is doing and make my own interpretation of it. Andy. Dan Moyer wrote: > Andy, > > Your listView single click detection method is clearly interesting & > simple, > sorry if I made it seem I didn't think it would work, I didn't mean to. > I'll try it too. I did get the gist of it, but your further explanation > also helped. But it was what I take to be a *general* debug idea you > suggested that I didn't really understand and which intrigued me. You > said, > > > > What I do is trap EVERY message in a trace(1) and see what sequence > > > > is likly to do what I want. this works fine for me, so it should > > > > for you to. > > Could you explain *that* idea a little more? > > Dan > > > ----- Original Message ----- > From: "Andy Drummond" <kestrelandy at xalt.co.uk> > To: "EUforum" <EUforum at topica.com> > Sent: Friday, October 19, 2001 10:42 AM > Subject: RE: ListView SINGLE-click detection > > > > Dan > > > > The idea is this: there seems to be no sensible event for a single > > click on a ListView. So I put a procedure in the listview onEvent[] > > list, and then every message for the listview gets to that procedure. > > > > There I look for what's needed, in this case a WM_PAINT when the item > > clicked on is re-painted with a highlight bar. I distinguish this from > > unhighlighting by seeing if this item is one I have already handled. > > So if it's a new item, I first remember which one it is so I don't > > do the works again, then I go do whatever I want on this single click. > > > > My routine is actually ShowSelected() which I use to show the details > > of the listview item I clicked on. That way I can click on items in a > > listview and as I do show the details in another window ... and it > > seems to work just dandy! It also seems very simple to implement with > > no problems.... just thought it might solve your problem ... > > > > Andy > > > > > > Dan Moyer wrote: > > > Andy, > > > > > > I *think* I can follow what you're doing, in your specific example, but > > > not > > > sure exactly what you mean by your general method of trapping every > > > message, > > > and it sounds useful! > > > > > > Here's approximately what Euman suggested, which *works* for single > > > click > > > detection: > > > > > > -- first make an extended style listview > > > global constant ListView2 = createEx( ListView, {}, Window1, 12, 16,680, > > > 132,or_all({LVS_REPORT,LVS_SINGLESEL}), or_all({LVS_EX_FULLROWSELECT, > > > LVS_EX_ONECLICKACTIVATE})) > > > > > > -- but since (apparently) the extended styles don't get properly set(?), > > > re-set them: > > > object junk > > > atom lvMask > > > -- makes full row selected, hand pointer moving on listview items > > > selects > > > them, > > > -- single click is responded to: > > > lvMask = or_all({LVS_EX_FULLROWSELECT,LVS_EX_TRACKSELECT , > > > LVS_EX_ONECLICKACTIVATE }) > > > > > > -- hovertime makes selection happen as quick as can move mouse: > > > junk = sendMessage( ListView2, LVM_SETHOVERTIME, 0, 1)-- 1=quick select > > > junk = sendMessage( ListView2, LVM_SETEXTENDEDLISTVIEWSTYLE, lvMask, > > > lvMask) > > > > > > -- & then in an onMouse event: > > > if event = WM_LBUTTONDOWN then > > > if getLVCount(ListView2) then > > > index = getLVSelected(ListView2) > > > if length(index) then > > > > > > > > > Dan > > > > > > > > > ----- Original Message ----- > > > From: "Andy Drummond" <kestrelandy at xalt.co.uk> > > > To: "EUforum" <EUforum at topica.com> > > > Sent: Friday, October 19, 2001 5:51 AM > > > Subject: ListView SINGLE-click detection > > > <snip>
3. RE: ListView SINGLE-click detection
- Posted by Andy Drummond <kestrelandy at xalt.co.uk> Oct 20, 2001
- 396 views
Hi there. I just posted a reply to Dan Moyer telling him what I did to find how to pick up the single-click on a listview. I have no idea if the paint is handled by the OS, as I said to Dan I have barely a glimmer of understanding of what Windows does and why it does it - I guess much like Microsoft! - so I just looked to see what happened and used what was useful. I have to say I'm not sure what demo you mean. The code in Dan's post looks obscure, with setting times and things, and I saw your addition, but at that point my method was up and running and I saw no merit in trying something different - even if it was more hygienic in terms of the way I should interface to Windows. I'm one of these guys who writes for little processors like PIC16 and when I get to Windows it reminds me of the old joke about "What is an elephant but a mouse running under Windows?". I love Euphoria and the IDE from Judith, it takes away all the horrors "normal" coding! Andy euman at bellsouth.net wrote: > Correct me if Im wrong but Paint events for Listview and treeview are > handled > by the O/S first off. Second did you try the demo Dan posted with my fix > in it? > I cant see the logic in your idea right off. > > Euman > euman at bellsouth.net > > > ----- Original Message ----- > From: "Andy Drummond" <kestrelandy at xalt.co.uk> > To: "EUforum" <EUforum at topica.com> > Sent: Friday, October 19, 2001 12:42 > Subject: RE: ListView SINGLE-click detection > > > > Dan > > > > The idea is this: there seems to be no sensible event for a single > > click on a ListView. So I put a procedure in the listview onEvent[] > > list, and then every message for the listview gets to that procedure. > > > > There I look for what's needed, in this case a WM_PAINT when the item > > clicked on is re-painted with a highlight bar. I distinguish this from > > unhighlighting by seeing if this item is one I have already handled. > > So if it's a new item, I first remember which one it is so I don't > > do the works again, then I go do whatever I want on this single click. > > > > My routine is actually ShowSelected() which I use to show the details > > of the listview item I clicked on. That way I can click on items in a > > listview and as I do show the details in another window ... and it > > seems to work just dandy! It also seems very simple to implement with > > no problems.... just thought it might solve your problem ... > > > > Andy > > > > > > Dan Moyer wrote: > > > Andy, > > > > > > I *think* I can follow what you're doing, in your specific example, but > > > not > > > sure exactly what you mean by your general method of trapping every > > > message, > > > and it sounds useful! > > > > > > Here's approximately what Euman suggested, which *works* for single > > > click > > > detection: > > > > > > -- first make an extended style listview > > > global constant ListView2 = createEx( ListView, {}, Window1, 12, 16,680, > > > 132,or_all({LVS_REPORT,LVS_SINGLESEL}), or_all({LVS_EX_FULLROWSELECT, > > > LVS_EX_ONECLICKACTIVATE})) > > > > > > -- but since (apparently) the extended styles don't get properly set(?), > > > re-set them: > > > object junk > > > atom lvMask > > > -- makes full row selected, hand pointer moving on listview items > > > selects > > > them, > > > -- single click is responded to: > > > lvMask = or_all({LVS_EX_FULLROWSELECT,LVS_EX_TRACKSELECT , > > > LVS_EX_ONECLICKACTIVATE }) > > > > > > -- hovertime makes selection happen as quick as can move mouse: > > > junk = sendMessage( ListView2, LVM_SETHOVERTIME, 0, 1)-- 1=quick select > > > junk = sendMessage( ListView2, LVM_SETEXTENDEDLISTVIEWSTYLE, lvMask, > > > lvMask) > > > > > > -- & then in an onMouse event: > > > if event = WM_LBUTTONDOWN then > > > if getLVCount(ListView2) then > > > index = getLVSelected(ListView2) > > > if length(index) then > > > > > > > > > Dan > > > > > > > > > ----- Original Message ----- > > > From: "Andy Drummond" <kestrelandy at xalt.co.uk> > > > To: "EUforum" <EUforum at topica.com> > > > Sent: Friday, October 19, 2001 5:51 AM > > > Subject: ListView SINGLE-click detection > > > > > > > > > > Dan et al, > > > > Reading back I just saw that the problem is in SINGLE-click > > > > detecting, not double click. So try this ... > > > > > > > > What I do is trap EVERY message in a trace(1) and see what sequence > > > > is likly to do what I want. this works fine for me, so it should > > > > for you to. > > > > > > > > > > > > atom LastLVpos -- Initialise to something, like -1 <snip>