Ask Your Question
0

How can I know if "Enter" is pressed in Text box? [closed]

asked 2017-08-23 03:16:07 +0200

shma_lo gravatar image

updated 2017-08-23 15:10:01 +0200

While entering info into text box, how can I know if key "Enter" is pressed? Or any other non-printable key? I don't need to see them, I want to start some other macro after key "Enter" is pressed.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by shma_lo
close date 2017-08-24 00:55:26.376505

2 Answers

Sort by » oldest newest most voted
1

answered 2017-08-23 15:07:49 +0200

Ratslinger gravatar image

Just check the key code. Attach to Key pressed (or released) event:

Sub KeyHandler_KeyPressed(oEvent)
    If oEvent.KeyCode = com.sun.star.awt.Key.RETURN Then
        Print "Enter key pressed"
    End If
    If oEvent.KeyCode = com.sun.star.awt.Key.TAB Then
        Print "Tab key pressed"
    End If
End Sub

Other constants - click here.

edit flag offensive delete link more

Comments

Thank you so much. It works perfect.

shma_lo gravatar imageshma_lo ( 2017-08-24 00:54:28 +0200 )edit

If this answers your question please click on the ✔ (upper left area of answer).

Ratslinger gravatar imageRatslinger ( 2017-08-24 00:55:38 +0200 )edit
0

answered 2017-08-23 09:03:38 +0200

Grantler gravatar image

updated 2017-08-23 09:04:58 +0200

In my opinion the non-formatting marks can't be shown in a text box (shape). For better control use text frames.

Nevertheless shapes are used as text boxes within other shapes (rectangles; circles...). But they seem to have other properties for inserted texts, they act like text frames. They show non printing marks.

edit flag offensive delete link more

Comments

Thank you, but I don't need to see them. I want to call some other macro if Enter is pressed.

shma_lo gravatar imageshma_lo ( 2017-08-23 15:08:38 +0200 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-23 03:16:07 +0200

Seen: 165 times

Last updated: Aug 23 '17