If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
List Box Click Event Anomaly.
"Peter Hibbs" wrote in message
... Thanks for the idea, your idea did not work What was wrong, if you don't mind my asking? I can't see why it wouldn't work, if implemented correctly. but I have found a solution using a similar method but the other way round. Regardless, I'm glad you found a solution. -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) |
#12
|
|||
|
|||
List Box Click Event Anomaly.
Dirk,
It could be that "implemented correctly" is the relevant part but I used this logic with the code below. When the mouse is down the vCheck flag is Set and when the mouse is released the vCheck flag is reset. When the list box gets the focus (with the TAB key) and the arrow keys are then pressed, the vCheck flag will be False and so the Click event will be triggered but is be ignored, i.e. the routine will exit immediately. And this works OK, the arrow keys move the cursor up and down the list of entries. My idea was that when the user actually clicked on a list box entry, the vCheck flag would be set True and so the Click event code would then execute. But it doesn't happen, it seems the flag is still False when the Click event triggers and the code just exits the routine. Private Sub lstClients_Click() If vCheck = False Then Exit Sub '...code here.... End Sub Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) vCheck = True End Sub Private Sub lstClients_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) vCheck = False End Sub If you have some alternative code I would be interested to see it although, as I said, my code does work. Peter Hibbs. On Wed, 10 Mar 2010 15:07:13 -0500, "Dirk Goldgar" wrote: "Peter Hibbs" wrote in message .. . Thanks for the idea, your idea did not work What was wrong, if you don't mind my asking? I can't see why it wouldn't work, if implemented correctly. but I have found a solution using a similar method but the other way round. Regardless, I'm glad you found a solution. |
#13
|
|||
|
|||
List Box Click Event Anomaly.
"Peter Hibbs" wrote in message
... Dirk, It could be that "implemented correctly" is the relevant part but I used this logic with the code below. When the mouse is down the vCheck flag is Set and when the mouse is released the vCheck flag is reset. When the list box gets the focus (with the TAB key) and the arrow keys are then pressed, the vCheck flag will be False and so the Click event will be triggered but is be ignored, i.e. the routine will exit immediately. And this works OK, the arrow keys move the cursor up and down the list of entries. My idea was that when the user actually clicked on a list box entry, the vCheck flag would be set True and so the Click event code would then execute. But it doesn't happen, it seems the flag is still False when the Click event triggers and the code just exits the routine. Private Sub lstClients_Click() If vCheck = False Then Exit Sub '...code here.... End Sub Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) vCheck = True End Sub Private Sub lstClients_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) vCheck = False End Sub If you have some alternative code I would be interested to see it although, as I said, my code does work. The sequence of events for a mouse click on a control is: MouseDown - MouseUp - Click So your code, which resets vCheck in the MouseUp event, will result in vCheck always being False in the Click event. You should reset vCheck in the Click event instead: '------ start of revised code ------ ' Declared at module level Dim vCheck As Boolean Private Sub lstClients_Click() If vCheck = False Then Exit Sub vCheck = False '...code here.... End Sub Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) vCheck = True End Sub '*** NO lstClients_MouseUp EVENT PROCEDURE *** '------ end of revised code ------ -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) |
#14
|
|||
|
|||
List Box Click Event Anomaly.
Dirk,
Yes, that works fine. I will use your solution, I think, as it is slightly simpler than mine. Thanks again. Peter Hibbs. On Thu, 11 Mar 2010 02:13:44 -0500, "Dirk Goldgar" wrote: "Peter Hibbs" wrote in message .. . Dirk, It could be that "implemented correctly" is the relevant part but I used this logic with the code below. When the mouse is down the vCheck flag is Set and when the mouse is released the vCheck flag is reset. When the list box gets the focus (with the TAB key) and the arrow keys are then pressed, the vCheck flag will be False and so the Click event will be triggered but is be ignored, i.e. the routine will exit immediately. And this works OK, the arrow keys move the cursor up and down the list of entries. My idea was that when the user actually clicked on a list box entry, the vCheck flag would be set True and so the Click event code would then execute. But it doesn't happen, it seems the flag is still False when the Click event triggers and the code just exits the routine. Private Sub lstClients_Click() If vCheck = False Then Exit Sub '...code here.... End Sub Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) vCheck = True End Sub Private Sub lstClients_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) vCheck = False End Sub If you have some alternative code I would be interested to see it although, as I said, my code does work. The sequence of events for a mouse click on a control is: MouseDown - MouseUp - Click So your code, which resets vCheck in the MouseUp event, will result in vCheck always being False in the Click event. You should reset vCheck in the Click event instead: '------ start of revised code ------ ' Declared at module level Dim vCheck As Boolean Private Sub lstClients_Click() If vCheck = False Then Exit Sub vCheck = False '...code here.... End Sub Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) vCheck = True End Sub '*** NO lstClients_MouseUp EVENT PROCEDURE *** '------ end of revised code ------ |
|
Thread Tools | |
Display Modes | |
|
|