LB Booster
« Single/double click »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:51am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: Single/double click  (Read 2631 times)
joker
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 157
xx Re: Single/double click
« Reply #10 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.
« Last Edit: Nov 9th, 2015, 10:37am by joker » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Single/double click
« Reply #11 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.
« Last Edit: Nov 9th, 2015, 9:11pm by Richard Russell » User IP Logged

joker
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 157
xx Re: Single/double click
« Reply #12 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.
User IP Logged

Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Re: Single/double click
« Reply #13 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.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Single/double click
« Reply #14 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.
User IP Logged

Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Re: Single/double click
« Reply #15 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.

User IP Logged

Rod
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 110
xx Re: Single/double click
« Reply #16 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.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Single/double click
« Reply #17 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 

« Last Edit: Nov 10th, 2015, 9:39pm by Richard Russell » User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Single/double click
« Reply #18 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.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Single/double click
« Reply #19 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.
User IP Logged

Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Re: Single/double click
« Reply #20 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

 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Single/double click
« Reply #21 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.
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: Single/double click
« Reply #22 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.
User IP Logged

joker
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 157
xx Re: Single/double click
« Reply #23 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?
« Last Edit: Nov 11th, 2015, 8:46pm by joker » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Single/double click
« Reply #24 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.
« Last Edit: Nov 11th, 2015, 9:26pm by Richard Russell » User IP Logged

Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls