Hello Drew,
On Sunday 30 August 2009, 13:49, Drew Jensen wrote:
> Ariel Constenla-Haile wrote:
> > Sub BtnPressed(oEvent as Object)
> > Dim oControl as Object
> > Dim oModel as Object
> >
> > oControl = oEvent.Source
> > oModel = oControl.getModel()
> >
> > End Sub
> >
> >
> > In this way, you can access the control and its model, and check what
> > button was pressed (by checking the control's model name, which is
> > unique; or by setting an action command to each button; etc. etc. use
> > your imagination)
>
> Just one caveat.
> The button names will be unique when you add them to a document via the
> controls toolbar or a wizard - but there is no requirement that they be so.
> Copy controls from one document to another and most likely they will not
> be. So you (the macro programmer) must take care not break uniqueness as
> you modify your controls if you intend to use the names in this fashion.
I guess you're talking about forms. But Johnny asked about dialogues, and here
the control's model name is unique: the css.awt.UnoControlDialogModel is a
container for control models and supports the css.container.XNameContainer
interface, which throws a css.container.ElementExistException if the name is
not unique.
Sub Main
Dim oDlg
oDlg = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
Dim oControlModel
oControlModel =
oDlg.getModel().createInstance("com.sun.star.awt.UnoControlFixedTextModel")
oControlModel.Label = "Label 1"
oControlModel.Width = 100
oControlModel.Height = 8
oDlg.getModel().insertByName("Demo1", oControlModel)
oControlModel =
oDlg.getModel().createInstance("com.sun.star.awt.UnoControlFixedTextModel")
oControlModel.Label = "Label 2"
oControlModel.Width = 100
oControlModel.Height = 8
oControlModel.PositionY = 9
oDlg.getModel().insertByName("Demo2", oControlModel)
oDlg.execute()
End Sub
Change "Demo2" by "Demo1" and you'll see it.
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]