Keep cursor at end of text (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 16:11
Joined
Jan 14, 2017
Messages
18,186
Access doesn't have a proper double click event. It times two single clicks, so it doesn't always work the way you want.

I would agree with that but your alternative code still relies on a double click event to trigger an action which rather defeats the object in my mind.

As mentioned in another thread, my personal preference is to use a small 'GoToEnd' button next to the textbox with code like this instead of the double click event:

Code:
Private Sub cmdEnd_Click()

       Me.txtJSON.SetFocus
       Me.txtJSON.SelStart = Me.txtJSON.SelLength 
      
        'next 2 lines optional but useful
       Me.cmdEnd.Enabled=False 
       Me.cmdStart.Enabled=True

End Sub

I also use another button to return to the start

Code:
Private Sub cmdStart_Click()

       Me.txtJSON.SetFocus
       Me.txtJSON.SelStart = 1
      
       'next 2 lines optional but useful
       Me.cmdStart.Enabled=False 
       Me.cmdEnd.Enabled=True

End Sub

 

Attachments

  • Capture.PNG
    Capture.PNG
    71.5 KB · Views: 204

static

Registered User.
Local time
Today, 16:11
Joined
Nov 2, 2015
Messages
823
I would agree with that but your alternative code still relies on a double click event to trigger an action which rather defeats the object in my mind.

I don't know what you mean. Double click doesn't work, the code I posted does.

In my code the double click is used but only to identify that the user double clicked. It doesn't 'trigger' anything.
 

isladogs

MVP / VIP
Local time
Today, 16:11
Joined
Jan 14, 2017
Messages
18,186
Double click code usually works but can fail in some situations where user takes longer to click again than the repeat interval defined in control panel

It seems to me this could similarly affect your code (though it works for you):

Code:
Private Sub Task_Update_DblClick(Cancel As Integer)
    goend = True
End Sub

If the double click doesn't get picked up here then goend is false so the mouse up event won't do anything

That's one reason why I prefer not to use double click events wherever possible
 

static

Registered User.
Local time
Today, 16:11
Joined
Nov 2, 2015
Messages
823
I'm not talking about mistimed clicks. I'm talking about the way Access handles double clicks can be a bit bugged.
 

isladogs

MVP / VIP
Local time
Today, 16:11
Joined
Jan 14, 2017
Messages
18,186
I've never noticed it being a problem other than where its detected as separate clicks.
 

static

Registered User.
Local time
Today, 16:11
Joined
Nov 2, 2015
Messages
823
Double clicking fires these events:

MouseDown
MouseUp
Click
DblClick
MouseUp

Only one mousedown but two mouseups?
And you can't have both a double and single click event because they both get fired.

Double clicking on text selects the clicked word - which Access does after the user event. Which I guess is what is screwing things up.
I put the code in Mouseup but (obvious now) you can just cancel the DblClick event which is much cleaner.

Code:
Private Sub Task_Update_DblClick(Cancel As Integer)
    Task_Update.SelLength = 0
    Task_Update.SelStart = Len(Task_Update.Text)
    Cancel = True
End Sub

Your button is a much better idea though, yes. You can see a button. Hidden events require user training.
 

Users who are viewing this thread

Top Bottom