LB Booster
Programming >> Language extensions >> Single/double click
http://lbb.conforums.com/index.cgi?board=extensions&action=display&num=1446953538

Single/double click
Post by Alincon on Nov 8th, 2015, 02:32am

Richard said:
"There's an undocumented feature of LB whereby you can enable both single- and double-click events from a listbox. I do not support that in LBB, although I could."

I have a program that DOES use both single and double click events
because I need to do two different things, and I didn't want to use a menu with only two choices.
I hope you will support this feature in the future.

r.m.
Re: Single/double click
Post by Richard Russell on Nov 8th, 2015, 10:30am

on Nov 8th, 2015, 02:32am, Alincon wrote:
I hope you will support this feature in the future.

Obviously undocumented features of LB have a low priority for being emulated in LBB (most of them are bugs anyway). How did you discover that you can enable both single and double clicks? Is it documented anywhere 'official'? Has Carl acknowledged that it's a supported feature?

Richard.

Re: Single/double click
Post by SarmedNafi on Nov 8th, 2015, 2:17pm

By code:

nomainwin

for i = 1 to 10
array$(i) = str$(i)
next

listbox #m.lb, array$(, [DoubleClickAction], 10, 10, 200, 200
statictext #m.txt, "Select an item or double click it.", 10, 220, 200, 40

open "test listbox event handlers" for window as #m
#m "trapclose [quit]"
#m.lb "singleClickSelect [SingleClickAction]"
wait

[SingleClickAction]
calldll #user32, "GetDoubleClickTime", delay as ulong
timer delay, [continue]
wait

[continue]
timer 0
#m.txt "Single Click Action"; chr$(13); "Double-Click-Delay: "; delay; "ms"

' reset selection
#m.lb "selectindex 0"
wait

[DoubleClickAction]
timer 0
#m.txt "Double Click Action"

' reset selection
#m.lb "selectindex 0"
wait

[quit]
close #m
end

'Regards
Re: Single/double click
Post by Richard Russell on Nov 8th, 2015, 3:23pm

on Nov 8th, 2015, 2:17pm, SarmedNafi wrote:
By code:

I know. But the LB docs say this:

Code:
print #handle.ext, "singleclickselect"

This tells Liberty BASIC to jump to the control's branch label on a single click,
instead of the default double click. 

It clearly states that the singleclickselect command causes a single click to have effect instead of a double click, not as well as! That is what is implemented in LBB, and I have no plans to change it.

Richard.


Re: Single/double click
Post by SarmedNafi on Nov 8th, 2015, 4:30pm

Sorry I back home right now,

I think he see the above which works on LB but not on LBB.
So he thought that LB has the ability of both events. And ask you to let LBB has the same (by modifying the code to work on LBB).

Regards,
Re: Single/double click
Post by Rod on Nov 8th, 2015, 8:18pm

You can have either a standard double click or enforce a single click. The code uses a timing trick to mimic the reading of a double click event but it is essentially using two single click events to achieve this.

So no undocumented abilities just a clever trick to differentiate user input. Problem I foresee is that you need clever users capable of understanding the difference.
Re: Single/double click
Post by Alincon on Nov 8th, 2015, 9:57pm

I think using both single and double clicks is useful code, not just a 'timing trick'

And it is documented in Liberty Basic Programmer's Encyclopedia.

r.m.
Re: Single/double click
Post by SarmedNafi on Nov 9th, 2015, 02:16am

This is slow a bit but it could solve the problem.
The single click of LBB took 500 ms.


WindowWidth = 482 : WindowHeight = 446
UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
for i = 1 to 10
List1$(i)= str$(i);"i";"i"
next
listbox #main.list1, List1$(), [SingleClick], 30, 20, 225, 345
Open "Window Title" for Window as #main
#main "trapclose [quit]"
#main.list1 "selectindex 1"
#main "font ms_sans_serif 10"
#main.list1 "singleclickselect [SingleClick]"
endtime = time$("ms")
what = time$("ms") - start
start = time$("ms")

[loop]
Wait

[SingleClick]
endtime = time$("ms")
what = time$("ms") - start
start = time$("ms")
'print what
timer 950, [c]
wait
[c]
timer 0
if what<=900 then Goto [double] else Goto [single]
wait

[single]
print "single"
wait

[double]
print "double"
wait

[quit]
close #main : END



Regards
Re: Single/double click
Post by SarmedNafi on Nov 9th, 2015, 03:23am

Replace with following part will work better.



-------
-------
------
[SingleClick]
endtime = time$("ms")
what = time$("ms") - start
start = time$("ms")
'print what
timer 1250, [c]
wait
[c]
timer 0
if what<=900 then Goto [double]
if what>1000 then Goto [single]
wait
------
------
------


Regards
Sarmed
Re: Single/double click
Post by Richard Russell on Nov 9th, 2015, 04:17am

In fact it appears that LB doesn't even work as it is documented to work. The docs say that sending a singleclickselect command causes the listbox to respond to a single-click instead of a double-click, and that's what I implemented in LBB. But in fact if you try it you'll find that, following that command, LB 4 responds to both a single and double click (but of course they trigger the same handler).

Note that it's not responding to two single clicks in quick succession as you might think, that's not how Windows works.

So this complicates things even more. Not only is there an undocumented feature, which is not supported in LBB, but even the documented functionality doesn't work as described so LBB isn't fully compatible with it. It's a mess.

Richard.
Re: Single/double click
Post by joker on Nov 9th, 2015, 10:36am

Here's what has resulted on the LB board since this was posted over there, too:

Quote:
Rod
Global Moderator
Re: singleclickselect with a branch label
« Reply #6 on: Today at 02:15am »
My understanding is that this is rooted in Windows protocol. Windows will issue a single click event AND a double click event if it happens in doubleclick time.

https://msdn.microsoft.com/en-us/library/ms171543(v=vs.110).aspx

So the control gets three events, a single click, another single click and then the double click. This has been the problem, there was never any point in trying for both events because the single would arrive first and always pre-empt the double.

Again, my understanding is that LB will react to single click events if enabled. If not they are just ignored and a double is needed to trigger activity. This is the default.

That is why the single click trick works in LB because it reacts to the second single click event that windows issues just ahead of the double. The double is ignored in this case.

Re: Single/double click
Post by Richard Russell on Nov 9th, 2015, 11:21am

on Nov 9th, 2015, 10:36am, pnlawrence wrote:
Rod: "Windows will issue a single click event AND a double click event if it happens in doubleclick time".

Yes, if both single-click and double-click events are enabled, with any control, a double-click event will always be accompanied by a preceding single-click event. Since the default double-click time is 500ms you would have to wait at least that long to find out which kind of event it really is, which is clunky and not user-friendly.

So in practice the only way you can sensibly use both events on the same control is when it doesn't matter that a 'spurious' single-click event accompanies every double-click. In other words the action that results from a single-click must be something fairly 'innocuous', or that can be later 'undone'.

It would be interesting to learn from Alincon what a single-click event does in his application, and why it doesn't matter that an extra event accompanies every double-click.

Quote:
Rod: "This has been the problem, there was never any point in trying for both events".

I wouldn't say "never" but certainly the issue discussed above, plus the fact that very few LB users know it is possible (and fewer still actually use the feature) makes me even more disinclined to support it in LBB.

Arguably, however, I ought sometime to modify LBB so that at least it works the same way as LB in the 'normal' singleclickselect mode, which is to activate the handler on both single and double clicks. That would be easy, involving actually removing code!

Richard.
Re: Single/double click
Post by joker on Nov 9th, 2015, 12:40pm

I knew you would get to the nitty-gritty.

Since getting into the GUI side of Windows only recently, I'm still amazed at how little can get done with so much code. wink

This double/single click thing is a good example of that.
Re: Single/double click
Post by Alincon on Nov 9th, 2015, 2:24pm

I don't know nothin 'bout milliseconds and extra clicks or documented or undocumented.

All I know is that when I singleclick on my listbox entry one thing happens and when I doubleclick on the same entry something else happens.

Of course, that's in LB. In LBB I only get one action, which I do not like.

r.m.
Re: Single/double click
Post by Richard Russell on Nov 9th, 2015, 2:40pm

on Nov 9th, 2015, 2:24pm, Alincon wrote:
All I know is that when I singleclick on my listbox entry one thing happens and when I doubleclick on the same entry something else happens.

I don't think so. Unless I've completely misunderstood how Windows works, when you singleclick one thing happens and when you doubleclick both things happen! That's the point Rod was making: you unavoidably get a 'spurious' single click event with every double-click.

My question was, how do you deal with that in your program? Does it just happen to be the case that the 'unwanted' single-click event doesn't matter?

Quote:
Of course, that's in LB. In LBB I only get one action, which I do not like.

I know this isn't helpful, but you (presumably) knew when you wrote your program that you were relying on undocumented behaviour. So you shouldn't be too upset to find it doesn't work in LBB.

If you can explain how your application responds to the two different user actions we may be able to suggest an alternative mode of operation that requires only one.

Richard.

Re: Single/double click
Post by Alincon on Nov 10th, 2015, 5:38pm

My code is not complicated or mysterious.
A double click causes a branch to the label in the listbox statement
A single click causes a branch to the label in the singleclick statement.
There are no flashes, hesitations or any detectable (to me) ill effects.

Rod does not think my code is kosher,
You have said you will not implement it in LBB.

So be it.

r.m.


Re: Single/double click
Post by Rod on Nov 10th, 2015, 6:18pm

I simply asked to see the code so that I could understand what the real issue was. Code explains everything, it is unusual to have two mouse actions on one control. At least if you discount right and left click which is better understood. But a single click and double click differentiation is unusual given the Windows hurdle to overcome.

If you do need it in LBB you need to make the case with code. The code will speak for itself.
Re: Single/double click
Post by Richard Russell on Nov 10th, 2015, 8:22pm

on Nov 10th, 2015, 5:38pm, Alincon wrote:
Rod does not think my code is kosher,
You have said you will not implement it in LBB.
So be it.

I have said that I probably should modify LBB to match the behaviour of the 'normal' singleclickselect command in LB 4, that is to activate the listbox handler on both single and double clicks (contrary to the documentation). With that trivial change it would be possible to distinguish between single and double clicks using the timer, as Sarmed and others have demonstrated.

The reason I keep asking how your existing program copes with the 'spurious' single click event (which accompanies every double click*) is that it may be that you are already using the timer - that's the approach the Liberty BASIC Programmer's Encyclopedia describes for separating the events. If that was the case the change to your code to support Sarmed's method might be minimal.

So between us we've offered you a complete solution to your problem that does not require the undocumented LB behaviour to be implemented in LBB.

Yet you don't seem to be interested. It seems that nothing less than full implementation of the undocumented LB feature will satisfy you, and as you say I am not at all keen to do that (it would not be an easy or risk-free modification).

Richard.

* Code for LB 4.04 or 4.5.0 (not LBB) to demonstrate that every double click is accompanied by a 'spurious' single click event (if it involves a change in the selected item):

Code:
    for i = 1 to 10
      array$(i) = str$(i)
    next

    listbox #w.lb, array$(), [doubleclick], 20, 20, 200, 200
    open "Test" for window as #w
    #w.lb "singleclickselect [singleclick]"
    wait

[doubleclick]
    print "Double click"
    wait

[singleclick]
    print "Single click"
    wait 


Re: Single/double click
Post by tsh73 on Nov 11th, 2015, 05:57am

I may be late with it but I think scenario there extra single click is of no harm is highly common.
See Windows Explorer
Single click selects file and shows little bit info on a status bar.
Double click starts "open file" operation or something *lengthy*
There is no harm if file will be selected first.

Re: Single/double click
Post by Richard Russell on Nov 11th, 2015, 08:20am

on Nov 11th, 2015, 05:57am, tsh73 wrote:
I may be late with it but I think scenario there extra single click is of no harm is highly common.

Indeed, especially so in Windows itself because the UI has been designed to suit the known behaviour.

Eliminating the 'spurious' single click event, which can only be done using a timer, really isn't satisfactory because it means a genuine single-click cannot be acted upon until at least 500 milliseconds later. It could be even longer, because the Double Click Delay is customisable.

So if you want to act on both single and double clicks, the only fully acceptable way is to design your UI so that the extra single-click event is of no harm, just like Windows Explorer etc. do. We don't know if that is the case in Alincon's application.

Richard.
Re: Single/double click
Post by Alincon on Nov 11th, 2015, 3:51pm

Here's what I think is the relevant code:

Code:
[appointments]
    WindowWidth = DisplayWidth :     WindowHeight = DisplayHeight
    BackgroundColor$ = "green"

    statictext #appt.st2, "Monday",    50, 20, 120, 20
    statictext #appt.st3, "Tuesday",   280, 20, 120, 20
    statictext #appt.st4, "Wednesday", 480, 20, 130, 20
    statictext #appt.st5, "Thursday",  680, 20, 130, 20
    statictext #appt.st6, "Friday" ,  910, 20, 130, 20

    statictext #appt.st8, "0800",  198, 60, 40, 20 : statictext #appt.st81, "0800",  825, 60, 40, 20
    statictext #appt.st9, "0900",  198, 92, 40, 20 : statictext #appt.st91, "0900",  825, 92, 40, 20
    statictext #appt.st10, "1000", 198, 124, 40, 20 : statictext #appt.st101, "1000", 825, 124, 40, 20
    statictext #appt.st11, "1100", 198, 156, 40, 20 : statictext #appt.st111, "1100", 825, 156, 40, 20
    statictext #appt.st11, "1200", 198, 188, 40, 20 : statictext #appt.st121, "1200", 825, 188, 40, 20
    statictext #appt.st01, "0100", 198, 220, 40, 20 : statictext #appt.st011, "0100", 825, 220, 40, 20
    statictext #appt.st02, "0200", 198, 252, 40, 20 : statictext #appt.st021, "0200", 825, 252, 40, 20
    statictext #appt.st03, "0300", 198, 284, 40, 20 : statictext #appt.st021, "0300", 825, 284, 40, 20
    statictext #appt.st04, "0400", 198, 316, 40, 20 : statictext #appt.st021, "0400", 825, 316, 40, 20
    listbox #appt.lbMon, mon$(, apptDel, 5,50,190,325
    Stylebits #appt.lbMon, _WS_HSCROLL, _WS_VSCROLL, 0, 0
    listbox #appt.lbTue, tue$(, apptDel, 230,50,190,325
    Stylebits #appt.lbTue, _WS_HSCROLL, _WS_VSCROLL, 0, 0
    listbox #appt.lbWed, wed$(, apptDel, 430,50,190,325
    Stylebits #appt.lbWed, _WS_HSCROLL, _WS_VSCROLL, 0, 0
    listbox #appt.lbThu, thu$(, apptDel, 630,50,190,325
    Stylebits #appt.lbThu, _WS_HSCROLL, _WS_VSCROLL, 0, 0
    listbox #appt.lbFri, fri$(, apptDel, 855,50,190,325
    Stylebits #appt.lbFri, _WS_HSCROLL, _WS_VSCROLL, 0, 0

        textbox #appt.tbx,10,85,1035,3   'horizontal 'lines'
        textbox #appt.tbx,10,117,1035,3
        textbox #appt.tbx,10,149,1035,3
        textbox #appt.tbx,10,181,1035,3
        textbox #appt.tbx,10,213,1035,3
        textbox #appt.tbx,10,245,1035,3
        textbox #appt.tbx,10,277,1035,3
        textbox #appt.tbx,10,309,1035,3
    button #appt.btn1,"<Last Week", [lastWeek], UL,330,440
    button #appt.btn2,"Next Week>", [nextWeek], UL,570,440
    button #appt.btn2,"  Enter  ", [apptEnter], UL,450,440

    open "APPOINTMENTS"  for window as #appt
    #appt, "trapclose [apptQuit]"
    #appt, "font ms_sans_serif 10"
    appt.open = 1
    #appt.lbMon,"SingleClickSelect patientCall"
    #appt.lbTue,"SingleClickSelect patientCall"
    #appt.lbWed,"SingleClickSelect patientCall"
    #appt.lbThu,"SingleClickSelect patientCall"
    #appt.lbFri,"SingleClickSelect patientCall"
    if left$(bothName$,8) = "Pat Call" then #appt.btn2,"!hide"
    dayNbr = date$("days") ' returns number - days since Jan 1, 1901
    dow = (dayNbr mod 7) + 3
    if dow > 7 then dow = dow - 7
    if dow = 7 then dayNbr = dayNbr - 5
    if dow = 6 then dayNbr = dayNbr - 4
    if dow = 5 then dayNbr = dayNbr - 3
    if dow = 4 then dayNbr = dayNbr - 2
    if dow = 3 then dayNbr = dayNbr - 1
    if dow = 1 then dayNbr = dayNbr + 1

   gosub [getApptFile]  ' brings in appointment data for the current week

 [apptLoop]
    wait

 sub patientCall x$ 
    #x$, "selection? patName$"
    patFileName$ = "patients\"+patName$ + "\"+patName$+".dat"
    files DefaultDir$, patFileName$, info$()
    if val(info$(0, 0)) = 0 then
       #x$,"selectindex 0"
    else
        open patFileName$ for input as #pat
            line input #pat, patRec$
        close #pat
        notice "Patient Phone";chr$(13);insert$(word$(patRec$,6,"|"),phTmplt$) ' phone #
    end if
    end sub  'wait

 sub apptDel x$ 
    confirm "Delete this Appointment?"; answer$ 
    if answer$ = "yes" then
        #x$, "selection? patNam$"
        #x$, "selectionindex? index"
        dy$ = right$(x$,3)
        adj = 1 - 2*(index mod 2 = 0)
         '   if index odd adj = 1.  if index even adj = -1
        select case dy$
        case "Mon"
             treat$ = mon$(index+adj)
             mon$(index) = "-" : mon$(index+adj) = "-"
        case "Tue"
             treat$ = tue$(index+adj)
             tue$(index) = "-" : tue$(index+adj) = "-"
        case "Wed"
             treat$ = wed$(index+adj)
             wed$(index) = "-" : wed$(index+adj) = "-"
        case "Thu"
             treat$ = thu$(index+adj)
             thu$(index) = "-" : thu$(index+adj) = "-"
        case "Fri"
             treat$ = fri$(index+adj)
             fri$(index) = "-" : fri$(index+adj) = "-"
        end select
        #x$,"Reload"

        call apptFileWrite appFileName$   ' rewrite appt file w/o deleted appt

        open patFileName$ for input as #pat  ' read patient file
            line input #pat, patRec$
        close #pat
        open patFileName$ for output as #pat ' rewrite w/o next visit field
            for n = 1 to 16
                print #pat, word$(patRec$,n,"|") +"|";
            next
            print #pat, " |"   ' blank next Visit field
        close #pat
        notice "DELETED";chr$(13);patNam$;"  "; treat$ 

    else
        #x$,"selectindex 0"
    end if
 [es]
    end sub

 

Re: Single/double click
Post by Richard Russell on Nov 11th, 2015, 5:19pm

on Nov 11th, 2015, 3:51pm, Alincon wrote:
Here's what I think is the relevant code:

OK, there's no TIMER so you don't have any code to kill the extra single-click event.

Here's a modification of my earlier demo program in which I've tried to distil the essence of your code:

Code:
    for i = 1 to 10
      array$(i) = "Patient ";i
    next

    listbox #w.lb, array$(), apptDel, 20, 20, 200, 200
    open "Demo for Alincon" for window as #w
    #w.lb "singleclickselect patientCall"
    wait

sub patientCall handle$
    notice "Patient phone"
end sub

sub apptDel handle$
    confirm "Delete this Appointment?"; answer$ 
end sub 

If I run it in LB 4.04 (not LBB) double-clicking doesn't give me the "Delete this Appointment?" prompt unless I double-click on the currently-selected item. If I double-click anywhere else I never see that prompt, instead I only see the "Patient phone" notice.

Is that what you get too? Is it what you want (it seems very user-unfriendly to me)? If this really is exactly the behaviour you want (i.e. the effect of double-clicking depending on whether the selection changes or not) I think I can confidently state that LBB is never likely to work that way.

In your position I would simply include a button for "Delete appointment".

Richard.

Re: Single/double click
Post by RNBW on Nov 11th, 2015, 6:41pm

on Nov 11th, 2015, 5:19pm, Richard Russell wrote:
If I run it in LB 4.04 (not LBB) double-clicking doesn't give me the "Delete this Appointment?" prompt unless I double-click on the currently-selected item. If I double-click anywhere else I never see that prompt, instead I only see the "Patient phone" notice.


This is also what happens in LB 4.5.

Can you imagine the irritation to the user in a program when they do the wrong type of click and don't get the result they expected. I agree with Richard, appropriate buttons would be the way to go, and certainly much clearer for the user.
Re: Single/double click
Post by joker on Nov 11th, 2015, 8:45pm

I think what Alincon is assuming is that the user would naturally either single or double click on the currently-selected item to perform one operation or the other.

So, the problem is that LB creates another exit from the listbox with the added single click.

I'm just trying to understand it for my own use. Am I understanding the problem right?
Re: Single/double click
Post by Richard Russell on Nov 11th, 2015, 9:09pm

on Nov 11th, 2015, 8:45pm, pnlawrence wrote:
I think what Alincon is assuming is that the user would naturally either single or double click on the currently-selected item to perform one operation or the other.

But clicking is how you change the selection (using the mouse) in a listbox. In the program I listed, if you single click on the currently selected item, as you propose, then nothing happens!

Put another way, to activate the single-click event the selection must change, but to activate the double-click event the selection must not change. If you think that's an intuitive way of operating I'm afraid I don't!

It seems to me possible that the reason the 'enable both events at once' feature is not documented is that it simply doesn't work in a consistent way. Maybe it's something Carl tried, found that it didn't work very well, but left enabled as an undocumented feature.

Richard.
Re: Single/double click
Post by Richard Russell on Nov 13th, 2015, 11:02am

Should the LB behaviour be what is wanted, and Alincon hasn't yet commented on that, it is not difficult to emulate it in LBB using a polling technique:

Code:
    for i = 1 to 10
      array$(i) = "Patient ";i
    next

    listbox #w.lb, array$(), apptDel, 20, 20, 200, 200
    open "Demo for Alincon" for window as #w
    timer 10, poll
    wait
    
sub poll
    global OldSel
    #w.lb "selectionindex? sel"
    if sel <> OldSel then
      OldSel = sel
      notice "Patient phone"      
    end if
end sub

sub apptDel handle$
    confirm "Delete this Appointment?"; answer$ 
end sub 

As it stands this code is LBB-only because it uses TIMER with a SUB handler (which crashes LB 4).

Richard.

Re: Single/double click
Post by Alincon on Nov 13th, 2015, 3:52pm

Think outside the (list) box. The five listboxes in the appointments window work together as a "spreadsheet" to display information about patient appointment, rather than their usual role as a list of items for selection. The columns are days , the rows are hours of the days. There are two things that can be done after after an appointment has been entered in the area below the grid: get a patient's phone number for reminder calls, and erase the data if an appointment is canceled.

I fail to see how assigning the two actions to single and double clicks would cause any user frustration, as compared to clicking an entry, moving the mouse off the grid, and clicking on one of two buttons.

Richard noted that clicking on an already chosen entry does nothing. But that is standard behaviour for a list box, is it not? I just neglected to add a set-index-to-zero command.

He also noted that clicking anywhere but on an entry does nothing. Yes What other behaviour would be expected? The entry to be deleted, or the patient phone number to be displayed is identified by it's location. If the entry clicked on is blank , nothing should happen, and nothing does

I am not demanding that LBB be changed to work as LB does, I only expressed a hope.

If Richard chooses not to change LBB in this case, that's final. He is the author of a very good software product and obviously the sole authority for changes or non-changes.

If he changes LBB in this case, I'll be pleased.
If not, no hard feelings, let's move on.

r.m.
Re: Single/double click
Post by Richard Russell on Nov 13th, 2015, 4:34pm

on Nov 13th, 2015, 3:52pm, Alincon wrote:
The five listboxes in the appointments window work together as a "spreadsheet"

So is there a specific reason why you don't use a spreadsheet? There are some very good LB spreadsheet emulations, e.g. using a grid of graphicboxes (remember that in LBB you can create them in a loop, so even a large grid isn't expensive in code).

Quote:
I fail to see how assigning the two actions to single and double clicks would cause any user frustration

The potential frustration is that they only work some of the time. Single-clicking on the currently-selected item doesn't work. Double-clicking on anything other than the currently-selected item doesn't work. This behaviour is not intuitive and therefore the user is likely to be surprised and irritated by it.

It seems to me that the problems arise primarily because you are trying to force a listbox to do something it was never intended to do, which is to emulate a column in a spreadsheet. There are other, and potentially better, ways to emulate a spreadsheet.

But if you are convinced that the way it works in LB is the way you want it to work, I gave you a complete LBB solution (using polling) in my reply of earlier today. As far as I know this behaves in a way which is indistinguishable from your LB code.

Richard.
Re: Single/double click
Post by SarmedNafi on Nov 14th, 2015, 01:39am

Richard,

Thank you, your example is wonderful, in fact it is act as the LISTBOX actually has the tow events built in either LBB or LB.
I impressed for these two examples it is better even than Stefans example the first one I post.

The following modified Richards code works on both LB and LBB.

Regards.

Code:
for i = 1 to 10
      array$(i) = "Patient ";i
    next

    listbox #w.lb, array$(), [apptDel], 20, 20, 200, 200
    open "Demo for Alincon" for window as #w
    #w "trapclose [quit]"

[loop]
    timer 100, [poll]
    wait
    
[poll]
timer 0
    #w.lb "selectionindex? sel"
    if sel <> OldSel then
      OldSel = sel
      Goto [selectAction]
    end if
goto [loop]

[apptDel]
    Goto [doubleClickAction]
    wait
     
[selectAction]
print "[selectAction]"
wait

[doubleClickAction]
print "[doubleClickAction]"
wait  

[quit]
close #w
End    
    
 

Re: Single/double click
Post by SarmedNafi on Nov 14th, 2015, 01:55am




I think this technique could be added to textbox and the text box portion of combobox too.

The replay to who said it is too much code is, we satisfy from the beginning to use a minimum amount of commands to build what ever we wants.
Re: Single/double click
Post by SarmedNafi on Nov 14th, 2015, 02:57am


Since first day I used Liberty Basic, I noticed there is no much control events I can use, specially with ListBox and ComboBox, the only choice is to select the item of the list box and click a button by a mouse, therefor I have to use many buttons to be clicked. The second thing is I can't use function buttons easily like with VB6, therefor I have to use timer to check a ROOT branch routine to trap all events I needs in my program.
Since the timer is broken under LB, or it doesn't work as documented, make LB very weak in such task.
Fortunately LBB is exist and has no such problems, we have to use it if we wants to build events system, Timer under LBB work fine.
Asking the authors to add features is a question could be not answers, therefor we have to accepts both LB and LBB as it is.

Sarmed
Re: Single/double click
Post by Richard Russell on Nov 14th, 2015, 09:36am

on Nov 14th, 2015, 02:57am, SarmedNafi wrote:
Since the timer is broken under LB, or it doesn't work as documented, make LB very weak in such task.

I have long since given up trying to understand Carl. I expected that he would either fix this bug in 4.5.0 or (if for some reason that proved impossible) change the documentation to state that TIMER cannot use a SUB handler. But he did neither, leaving each new LB user to discover for themselves that it crashes. sad

Richard.