[Solved] Detect mouse press in msgbox

Keyboard macros or custom scripts

[Solved] Detect mouse press in msgbox

Postby kevinT220 » Tue Dec 01, 2020 8:08 am

Im new to Javascript . Sry if i asking a stupid question.
I used msgbox to display an error message , in the boxmsg got a yes button, how i can only allow mouse press at yes button, then the msgbox only close.
i find one coding is something like com.sun.star.awt.MouseButton.LEFT but i dk how to add in.
Last edited by kevinT220 on Mon Dec 07, 2020 7:42 am, edited 2 times in total.
Apache OpenOffice4.1.7
kevinT220
 
Posts: 11
Joined: Wed Nov 18, 2020 5:43 am

Re: Detect mouse press in msgbox

Postby Zizi64 » Tue Dec 01, 2020 9:18 am

You can use the MsgBox as a function. The return value is an integer number: it show you which button was pushed (by a mouse click). See it in the Help.
Tibor Kovacs, Hungary; LO6.1.6, 6.4.7 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.1.1;AOO4.1.9
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 9840
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Detect mouse press in msgbox

Postby JeJe » Tue Dec 01, 2020 2:51 pm

You can choose which buttons to show and only have an OK button if you wish. This is from the help file for BASIC,

MsgBox Function [Runtime]
Displays a dialog box containing a message and returns a value.
Syntax:
MsgBox (Text As String [,Type As Integer [,Dialogtitle As String]])
Return value:
Integer
Parameter:
Text: String expression displayed as a message in the dialog box. Line breaks can be inserted with Chr$(13).
DialogTitle: String expression displayed in the title bar of the dialog. If omitted, the name of the respective application is displayed.
Type: Any integer expression that specifies the dialog type and defines the number and type of buttons or icons displayed. Type represents a combination of bit patterns (dialog elements defined by adding the respective values):
Values
0 : Display OK button only.
1 : Display OK and Cancel buttons.
2 : Display Abort, Retry, and Ignore buttons.
3 : Display Yes, No, and Cancel buttons.
4 : Display Yes and No buttons.
5 : Display Retry and Cancel buttons.
16 : Add the Stop icon to the dialog.
32 : Add the Question icon to the dialog.
48 : Add the Exclamation Point icon to the dialog.
64 : Add the Information icon to the dialog.
128 : First button in the dialog as default button.
256 : Second button in the dialog as default button.
512 : Third button in the dialog as default button.
Return value:
1 : OK
2 : Cancel
3 : Abort
4 : Retry
5 : Ignore
6 : Yes
7 : No
Error Codes
5 Invalid procedure call
Example:
Sub ExampleMsgBox
Dim sVar as Integer
sVar = MsgBox("Las Vegas")
sVar = MsgBox("Las Vegas",1)
sVar = MsgBox( "Las Vegas",256 + 16 + 2,"Dialog title")
end sub



Edit: Javascript appears to have an OK only choice as well

https://www.w3schools.com/js/js_popup.asp
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1532
Joined: Wed Mar 09, 2016 2:40 pm

Re: Detect mouse press in msgbox

Postby kevinT220 » Thu Dec 03, 2020 11:31 am

can i set no default button on MsgBox?
Apache OpenOffice4.1.7
kevinT220
 
Posts: 11
Joined: Wed Nov 18, 2020 5:43 am

Re: Detect mouse press in msgbox

Postby JeJe » Fri Dec 04, 2020 4:14 pm

If you create your own dialog you can do whatever you want with it. All a MsgBox is is a dialog with a couple of buttons.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1532
Joined: Wed Mar 09, 2016 2:40 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 4 guests