How to simulate "focus lost" to have recalc of cells?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Gerald63
Posts: 7
Joined: Mon Dec 13, 2021 2:00 pm

How to simulate "focus lost" to have recalc of cells?

Post by Gerald63 »

Hello,

i have a simple problem with changes of a textfield.

Functio below is used to be able to set some defaults in a sheet:

Code: Select all

function setTextField(FormName,FieldName ,  value)
  Dim oSheets
  Dim oSheet
  Dim oCell    
  vForm=THISCOMPONENT.CurrentController.ActiveSheet.DrawPage.Forms.getByName(FormName)
  vTextField = vForm.getByName(FieldName)
  vTextField.Text=value  
end function  
This works fine but after the change of a formatted textfield the dependent cells in the sheet are not recalculated. How to simulate a "lost focus" or something like that at the end of this function?

Where can I find a documentation of all of the members methods of the object getByName returns in vTextField? Since this is typeless BASIC and not C++ or JAVA I'm a little bit lost here.
Where to get additional information.

regards
Gerald
regards
Gerald
OS: Windows 10 / Ubuntu Linux
Open Office: 4.1.11
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to simulate "focus lost" to have recalc of cells?

Post by Villeroy »

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Gerald63
Posts: 7
Joined: Mon Dec 13, 2021 2:00 pm

Re: How to simulate "focus lost" to have recalc of cells?

Post by Gerald63 »

Thanks,
this works, maybe I will sind a member or methode which will do this job. Gives me some additional information about the stuff used by myself.

Maybe I can simulate a KeyPress with this or send just a Focus Lost event to a field changed by a macro.


regards
Gerald
regards
Gerald
OS: Windows 10 / Ubuntu Linux
Open Office: 4.1.11
Gerald63
Posts: 7
Joined: Mon Dec 13, 2021 2:00 pm

Re: How to simulate "focus lost" to have recalc of cells?

Post by Gerald63 »


This seems not to work. MRI show the properties of the cells below the cursor but there are above the cells formatted text fields in a form to have at these position the possibility to react on "key pressed".
The formatted text field offer DMS format (123°45,6'78.9'').
When the field is edited it automaticly compute decimal format and set this in a regular cell because it's easier to do all of the math required to have the result with decimals. This works so fa so good.

I want to offer the users of my spreadsheet a "Reset" button which removes everything from the editable fields and two buttons which set example data. The point is that the example buttons fills the formatted text fields but do not trigger the calculation of all of the regular fields like manual editing do (No key pressed event or focus lost event).

No clue what to do.

Thanks a lot for some help.


regards
Gerald


P.S. I can do it the "poor persons" way and just call all of the Key Pressed methods for all of the fields in a complex "if then" or "case" construct but that's not really what I like to do.
regards
Gerald
OS: Windows 10 / Ubuntu Linux
Open Office: 4.1.11
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to simulate "focus lost" to have recalc of cells?

Post by Villeroy »

MRI is indispensible for anyone trying to write macros.
Point the key pressed event to MriLib>Standard>MRI and inspect the event.
Or get MRI for the current selection, dbl-click Spreadsheet --> DrawPage --> Forms --> method getByIndex() --> 0 --> getByName --> control name

Why don't you abandon all that Basic bullshit and use a simple template with scenarios?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 2781
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to simulate "focus lost" to have recalc of cells?

Post by JeJe »

Code: Select all

P.S. I can do it the "poor persons" way
Done it and moved on is the rich person's way. Time rich... not wasting it...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2781
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to simulate "focus lost" to have recalc of cells?

Post by JeJe »

But, if you provide a stripped down sample document with your reset button in showing why it doesn't work and what you want... people can look at the problem.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply