Ask Your Question
0

PropertyChangeListener on TextField.Input

asked 2015-06-10 21:11:41 +0200

mike_papa gravatar image

updated 2015-08-25 18:54:59 +0200

Alex Kemp gravatar image

4.4.3.2, Polish, Writer Windows 8.1, Polish

Document is Writer, with single Input field (nothing else in it), and here is my code:

Global oListener as Object
Global oVetoListener as Object
Global oInput as Object

Sub Listen
    oInput = GetTextInputField(ThisComponent, "a")
    oListener = createUnoListener("MyEvent_", "com.sun.star.beans.XPropertyChangeListener")
    oInput.addPropertyChangeListener("", oListener)

End Sub

Sub StopListen
    oInput.removePropertyChangeListener("", oListener)
End Sub

Sub MyEvent_disposing(oEvent)
    MsgBox "disposing"
End Sub

Sub MyEvent_propertyChange(oEvent)
    MsgBox "modified"
End Sub

Function GetTextInputField(Doc as Object, FieldName as String) as Object
    Dim TextFields as Object
    Dim TextField as Object
    TextFields = Doc.getTextFields.createEnumeration
    While TextFields.hasMoreElements()
        TextField = TextFields.nextElement()
        If TextField.supportsService("com.sun.star.text.TextField.Input") Then
            If TextField.Hint = FieldName Then
                GetTextInputField = TextField
            End If
        End If
    Wend
End Function

Sub ShowContent
    F = GetTextInputField(ThisComponent, "a")
    MsgBox F.getPropertyValue("Content")
End Sub

ShowContent shows Input field content corectly, so I assume GetTExtInputField works fine. Unfortunately nothing happends on Content change. I have tried both

oInput.addPropertyChangeListener("", oListener)

and

oInput.addPropertyChangeListener("Content", oListener)

None of them works. What is the problem?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2015-06-11 02:05:58 +0200

KeithSand gravatar image

"Content" is an attribute of "Input", not a member of it's property set. I suggest the modify listener.

edit flag offensive delete link more

Comments

I'm fairly new to Basic, with more expirience in python, but: oInput.DBG_properties in Listen returns: Properties of object "SwXTextField": SbxSINGLE IsFieldUsed; SbxSTRING Content; [...] "Content" is listed as a property. I must be clearly missing something here on fundamental level if you are right.

mike_papa gravatar imagemike_papa ( 2015-06-12 00:01:41 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-06-10 21:11:41 +0200

Seen: 114 times

Last updated: Jun 11 '15