Ask Your Question
0

Calc BASIC | How to alter the previously opened dialog to be active ? And is there double click event for grid in dialog?

asked 2020-02-17 10:34:13 +0100

lonk gravatar image

updated 2020-03-03 17:17:29 +0100

1.Two dialogs poped up, only the latest one must be active.

Is it possible to alter the previously opened dialog to be active ?

2.If only 'Budget System - Average Expenses' is active, I need to double click on grid row number 2 in order to get the content of first cell, 'Utilities', to be placed in Calc cell B6.

Is there double click event for grid and sample codes?

3.I have adapted BASIC codes from Base to use in Calc BASIC of C:\fakepath\0006.ods.

Library1 > Module1Original > AvgExpenseDialog

In Calc BASIC line 138, oDialogModel.Title = "GridControl Test" does not show in dialog.

What is this line used for ?

image description


*Edited March 3, 2020:

Attached file : C:\fakepath\15825140369332625_1.ods for the comment today.*

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-02-17 23:22:41 +0100

Ratslinger gravatar image

updated 2020-02-24 04:15:44 +0100

Hello,

Please keep to single questions. Multiple get buried from others looking for answers.

Also note that you are basing information on an almost 4 year old question (not an answer). This question was actually asked to have the grid available in a form (not possible to my knowledge). This code was strictly a bunch of code doing a variety of tests and not necessarily all productive. There is a lot of digging just to understand the basics of constructing a grid control.

Your questions:

1.Two dialogs poped up, only the latest one must be active.

Is it possible to alter the previously opened dialog to be active ?

First, if you want the other dialog to be active just click on the header of the dialog. If you did not want to have both opened, close one with code before opening the other. With code set the dialogs as global and end the execution of what is not wanted.

And how is it know which one was previously opened? In this cas you talk of two. What if there were more? What if they were reversed? Need logic to determine what is what.

2.If only 'Budget System - Average Expenses' is active, I need to double click on grid row number 2 in order to get the content of first cell, 'Utilities', to be placed in Calc cell B6.

Is there double click event for grid and sample codes?

Here is what is available -> com::sun::star::awt::grid Module Reference

There is nothing for a double click. There is a selection listener. Here is a post incorporating that -> Libre Office custom Dialog Table

Edit

Attaching a sample. The first dialog (original) has a key handler attached. When a row is selected & Enter key is used the row with first column entry is displayed. This would be used for your entry to the sheet.

The second dialog uses a mouse handler. Found a method for double click. So a double click on a row will display the data.

Sample (Revised mouse double click) ---- DialogsOrig.ods

End Edit

3.I have adapted BASIC codes from Base to use in Calc BASIC of C:\fakepath\0006.ods.

Library1 > Module1Original > AvgExpenseDialog

In Calc BASIC line 138, oDialogModel.Title = "GridControl Test" does not show in dialog.

What is this line used for ?

As stated in the beginning, this was a lot of testing. oDialogModel was part of the tests. Nothing shows for this as the actual was based upon oDlgModel.

Edit 2020-02-23:

It appears, based on questions elsewhere, you may not have a handle on listeners. Here is another sample. It contains two menu selections (your insertion). The first uses Account code grid. A double mouse click will insert the code into the selected cell on the sheet. The second selection uses the Item grid. Any selection here will enter the item into the selected cell on your sheet. NOTE: If you use a Print or MsgBox in ... (more)

edit flag offensive delete link more

Comments

@lonk,

Tried testing with an event handler and had problems. When I posted my original question if recalled correctly, the events worked. Have tested with some other definitions and none work. Maybe something has broken in LO.

Example post -> https://dev.api.openoffice.narkive.co...

Also another post of general interest -> http://www.mic-consulting.de/de/artik...

Ratslinger gravatar imageRatslinger ( 2020-02-18 02:42:37 +0100 )edit

@lonk,

Possibly using a key listener may help. Initial test shows com.sun.star.awt.XKeyListener to work.

Ratslinger gravatar imageRatslinger ( 2020-02-18 04:08:57 +0100 )edit

@lonk,

Have done some further testing with multiple open non-modal dialogs. Although you can bring to the front one or the other, only the last one opened is actually active. Only method I have found to make the inactive dialog active is to end the execution and then execute it again. This then makes the other dialog inactive until this last one has execute ended.

If both are needed simultaneously (or alternately), consider placing two grid controls on one dialog.

Ratslinger gravatar imageRatslinger ( 2020-02-18 19:18:16 +0100 )edit

Dear @Ratslinger,

placing two grid controls on one dialog

That is the great idea, thank you so much.

lonk gravatar imagelonk ( 2020-02-24 05:53:28 +0100 )edit

@lonk,

Hope you saw my last edit in the answer with a new sample. It completes your request here and with another post you have had.

Ratslinger gravatar imageRatslinger ( 2020-02-24 05:58:46 +0100 )edit

Dear @Ratslinger,

And thank you so much again for your examples.

lonk gravatar imagelonk ( 2020-02-24 06:10:30 +0100 )edit

Dear @Ratslinger,

Sorry for many comments.

There was an error message from running Sub PopupGridDialog in Library1 > Module2Modified of GridSelection.ods .

The IDE hilighted at line 162, Globalscope.BasicLibraries.LoadLibrary( "MRILib" ) .

The error message is:

Basic runtime error:

An exception occurred.

Type: com.sun.star.container.NoSuchElementException.

Message:.

Help me please.

lonk gravatar imagelonk ( 2020-02-24 06:36:25 +0100 )edit

@lonk,

Sorry for the inconvenience. Just delete that line. Can also delete the following line containing commented out Mri. This is for an object inspection tool to examine settings and methods.

If you want more information on this tool, see links at the end of my answer here -> Elements for GetRegistryKeyContent("org.openoffice.Setup/Product")

Ratslinger gravatar imageRatslinger ( 2020-02-24 17:00:07 +0100 )edit

Dear @Ratslinger,

From this Sub for doubleclick event,

how can the dialog be closed as well within this event of double click?

Sub XMouseHandler_mousePressed(oEvt)
    Dim selectedValue       As String
    Dim oSheet              As Object
    Dim oCurrentSelection   As Object
    Dim aCellAddress
    Dim nColumn             As Integer
    Dim nRow                As Integer
    Dim oSelectedCell       As Object
    If oEvt.ClickCount = 2 Then
        selectedValue       = gGrid(oEvt.Source.CurrentRow + 1, 1)
        oSheet              = ThisComponent.CurrentController.ActiveSheet
        oCurrentSelection   = ThisComponent.getCurrentSelection()
        aCellAddress        = oCurrentSelection.getCellAddress()
        nColumn             = aCellAddress.Column
        nRow                = aCellAddress.Row
        oSelectedCell       = oSheet.getCellByPosition(nColumn, nRow)
        oSelectedCell.setString(selectedValue)
    End If

    'Close the dialog

End Sub
lonk gravatar imagelonk ( 2020-03-01 17:25:06 +0100 )edit

Make oDlg global and before End If:

    oDlg.endExecute()
Ratslinger gravatar imageRatslinger ( 2020-03-01 22:19:00 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-02-17 10:34:13 +0100

Seen: 145 times

Last updated: Mar 03