Author |
Topic: Single/double click (Read 2626 times) |
|
Alincon
Full Member
member is offline


Posts: 147
|
 |
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.
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline


Gender: 
Posts: 110
|
 |
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.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
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.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
Logged
|
|
|
|
Alincon
Full Member
member is offline


Posts: 147
|
 |
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
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
Logged
|
|
|
|
RNBW
Full Member
member is offline


Gender: 
Posts: 106
|
 |
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.
|
|
Logged
|
|
|
|
joker
Global Moderator
member is offline


Gender: 
Posts: 157
|
 |
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 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Single/double click
« Reply #25 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.
|
|
Logged
|
|
|
|
Alincon
Full Member
member is offline


Posts: 147
|
 |
Re: Single/double click
« Reply #26 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.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Single/double click
« Reply #27 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.
|
|
|
|
SarmedNafi
Junior Member
member is offline


Posts: 93
|
 |
Re: Single/double click
« Reply #28 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
|
| « Last Edit: Nov 14th, 2015, 02:34am by SarmedNafi » |
Logged
|
|
|
|
SarmedNafi
Junior Member
member is offline


Posts: 93
|
 |
Re: Single/double click
« Reply #29 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.
|
|
Logged
|
|
|
|
|