[Solved] Event isn't working !

Discuss the database features
Post Reply
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

[Solved] Event isn't working !

Post by arfgh »

Hey there.

I have a document form with a sub-form that show a table grid control. In one of its columns i have set an event when the mouse button is release to run my function. Works fine, but.... now Instead to set a table as data source, i created a SQL command as data source to fill the table grid with the command result.

As soon as i did that change, the event didnt work anymore. In fact the function is never called. When i click on some cell on the column i added the event, isnt getting blue selected as before, only cell border obtain the focus now.

Why ? which is the problem ? how to fix it ?

thx in advance
Last edited by Hagar Delest on Sat Sep 09, 2017 10:12 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Event isnt working !

Post by UnklDonald418 »

The reason for your problem is:
now Instead to set a table as data source, i created a SQL command as data source
The SQL command only displays data on the table.
isnt getting blue selected as before, only cell border obtain the focus now.
Is telling you the data on the table can't be edited, as a result there is no Event.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Event isnt working !

Post by UnklDonald418 »

I should point out that queries that join multiple tables result in Table controls where the data fields can't be edited.
If the query references a single table then the Table control will allow editing, and Events will work.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Event isnt working !

Post by Arineckaig »

queries that join multiple tables result in Table controls where the data fields can't be edited
While this is often the case, I believe a work-around is available.

See [Example] Queries that can edit multi-tables. It will only work, however, if the Query/SQL is routed via the Base parser: direct SQL mode is not effective.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Event isn't working !

Post by arfgh »

yes, the table cant be edited because it is filled by the sql command, that's clear, but what have to be with that question the event ?
In my opinion the event must jump as before, because there isnt a reason to dont do it, i think.

Anyways you said that is some way to do it, how about it ?

The reason i need that event on certain table grid column, is to open other form with the filter to the text on the table cell, a very useful feature.

thx in advance
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Event isn't working !

Post by UnklDonald418 »

In my opinion the event must jump as before, because there isnt a reason to dont do it, i think.

Apparently the OO developers didn't share your opinion. Events are triggered by a change on the cell, and since the cells on your table can't change no events will be triggered.
As the example Arineckaig posted explains, if you change your query so that it contains all the Primary Keys and Foreign keys in all the joined database tables, then your form table may allow changes and the events should work.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Event isn't working !

Post by arfgh »

but we have a property to set 'the table cant be edited'.
Still i dont understand why the event isnt jumping because if the table cant be edited, what is bad with the event ?
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Event isn't working !

Post by Arineckaig »

arfgh:
In one of its columns i have set an event when the mouse button is release to run my function.
For a macro to reference the value of a particular cell in a grid form control, my tests indicate it is sometimes more reliable if the source of the calling event is the grid form control itself rather than one of its contained column form controls. The view and model properties of the grid form control supply respectively direct references to the column selected and to the relevant record of the underlying RecordSet.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Event isn't working !

Post by arfgh »

you meant to place the event in the whole trable grid control, instead in the column ? But then how we will catch the clicked cell content text ?
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: Event isn't working !

Post by hubert lambert »

Hello,

Depending of what type of value you want to retrieve, here's two methods following Arineckaig's advice:

Code: Select all

sub themacro(event)
    grid = event.Source
    column = grid.CurrentColumnPosition
    selection = grid.getByIndex(column)
    msgbox selection.Text
end sub

Code: Select all

sub themacro(event)
    grid = event.Source
    column = grid.CurrentColumnPosition
    form = grid.Model.Parent
    msgbox form.getString(column +1)
end sub    
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Event isn't working !

Post by Arineckaig »

arfgh asks:
Still i dont understand why the event isnt jumping because if the table cant be edited, what is bad with the event ?
Where data displayed in a Grid form control cannot - for whatever the reason - be updated, the Base GUI prevents the visible selection of that content. Such action could well be considered to be user friendly, as the lack of visible change gives warning against the frustration of futile but often repeated key entries or mouse clicks.

Prevention of visible selection thus appears to forestall the trigger of consequential events. It can only be a matter of opinion whether that represents a bug or a useful feature.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Event isn't working !

Post by arfgh »

wanted to know also the opinion of Villeroy, it is very strange he hasnt said anything yet.....
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Event isn't working !

Post by Arineckaig »

+ 1
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Event isn't working !

Post by arfgh »

well, it is truth that with the event in the whole table grid the event is jumping again. but... 'column = grid.CurrentColumnPosition' that isnt working here, the error is : 'not valid object'

i think that 'CurrentComunPosition' doesnt exists...

help
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Event isn't working !

Post by Arineckaig »

In my earlier post
The view and model properties of the grid form control supply respectively direct references to the column selected and to the relevant record of the underlying RecordSet.
The .CurrentColumnPosition property belongs to the View of a grid form control: it does not exist as a property of that control's Model. On the other hand it is its Model that holds the more direct reference to the particular record (aka. row) that has been selected.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Event isn't working !

Post by arfgh »

ok.... and following the same, is there a way to obtain the column name or index ?
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Event isn't working !

Post by Arineckaig »

a way to obtain the column name or index ?
The View of the Grid Form Control has a .getCurrentColumnPosition() property that supplies the relevant column index number. In turn, that index number is applicable to the Model of the Grid Form Control to obtain that column's .Name property.

You will be aware that the .Source property of an event set to trigger a macro, may for some events reflect the View and for other events the Model of calling object. Hence, Star BASIC code does not always readily lend itself to being copied from one application to another.

The following example has been tested, and is offered, on the presumption it is to be called by a Mouse Button Released event of the Grid Form Control - i.e. a cell in the table has been selected:

Code: Select all

Sub ShowSelectedColumnIndexName
oGridV = oEv.Source	    REM the view of the Grid
nColNum = oGridV.getCurrentColumnPosition()
sColName = oGridV.Model.getByIndex(nColNum).Name
Print nColNum, sColName
End Sub
It may be unsuitable for other Grid Form Control events. I find the MRI extension to be invaluable for showing whether the View or Model reflects the .Source of an event. For example, a temporary (later to be deleted or REMmed out) first line of a new macro, that is to be developed, can be set as:

Code: Select all

 Sub NewMacro(oEv)
MRI oEv.Source : Exit Sub
End Sub 
It not only displays whether the View or Model is the starting point but also permits the exploration and testing of potential routes from that point by which the OpenOffice API may be persuaded to reveal its strengths and secrets.

Please come back if you have difficulties with the MRI facility. You may well, however, prefer other means for exploring the API.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Event isn't working !

Post by arfgh »

Yes i tried several times to use the mri extension and helped some in cases, so thx for that little example to explore with it :)

well at finally was possible to have again the event jumping. Yes, was very strange that thing where the event isnt working because using a query... thx
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Post Reply