Difference between revisions of "Documentation/DevGuide/Basic/Dialog as Control Container"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
Line 8: Line 8:
 
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Basic/{{SUBPAGENAME}}}}  
 
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Basic/{{SUBPAGENAME}}}}  
 
  {{DISPLAYTITLE:Dialog as Control Container}}
 
  {{DISPLAYTITLE:Dialog as Control Container}}
All controls belonging to a dialog are grouped together logically. This hierarchy concept is reflected by the fact that a dialog control is a container for other controls. The corresponding service <idl>com.sun.star.awt.UnoControlDialog</idl> therefore supports the <idl>com.sun.star.awt.XControlContainer</idl> interface that offers container functionality, namely access to its elements by name. Since in {{PRODUCTNAME}} Basic, every method of every supported interface is called directly at the object without querying for the appropriate interface, a control with the name TextField1 can be obtained from a dialog object <code>oDialog</code> simply by:
+
All controls belonging to a dialog are grouped together logically. This hierarchy concept is reflected by the fact that a dialog control is a container for other controls. The corresponding service <idl>com.sun.star.awt.UnoControlDialog</idl> therefore supports the <idl>com.sun.star.awt.XControlContainer</idl> interface that offers container functionality, namely access to its elements by name. Since in {{AOo}} Basic, every method of every supported interface is called directly at the object without querying for the appropriate interface, a control with the name TextField1 can be obtained from a dialog object <code>oDialog</code> simply by:
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
   oControl = oDialog.getControl("TextField1")
 
   oControl = oDialog.getControl("TextField1")
</source>
+
</syntaxhighlight>
 
See [[Documentation/DevGuide/ProUNO/Basic/OpenOffice.org Basic|OpenOffice.org Basic]] for additional information. The hierarchy between a dialog and its controls can be seen in the dialog model <idl>com.sun.star.awt.UnoControlDialogModel</idl>, which is a container for control models and therefore supports the <idl>com.sun.star.container.XNameContainer</idl> interface. A control model is obtained from a dialog model by:
 
See [[Documentation/DevGuide/ProUNO/Basic/OpenOffice.org Basic|OpenOffice.org Basic]] for additional information. The hierarchy between a dialog and its controls can be seen in the dialog model <idl>com.sun.star.awt.UnoControlDialogModel</idl>, which is a container for control models and therefore supports the <idl>com.sun.star.container.XNameContainer</idl> interface. A control model is obtained from a dialog model by:
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
   oDialogModel = oDialog.getModel()
 
   oDialogModel = oDialog.getModel()
 
   oControlModel = oDialogModel.getByName("TextField1")
 
   oControlModel = oDialogModel.getByName("TextField1")
</source>
+
</syntaxhighlight>
 
or shorter:
 
or shorter:
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
   oControlModel = oDialog.Model.TextField1
 
   oControlModel = oDialog.Model.TextField1
</source>
+
</syntaxhighlight>
 
The model of a control is also returned by the <code>getModel()</code> method of the control. In short notation:
 
The model of a control is also returned by the <code>getModel()</code> method of the control. In short notation:
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
   oControlModel = oControl.Model
 
   oControlModel = oControl.Model
</source>
+
</syntaxhighlight>
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]
 
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]

Latest revision as of 21:20, 20 December 2020



All controls belonging to a dialog are grouped together logically. This hierarchy concept is reflected by the fact that a dialog control is a container for other controls. The corresponding service com.sun.star.awt.UnoControlDialog therefore supports the com.sun.star.awt.XControlContainer interface that offers container functionality, namely access to its elements by name. Since in Apache OpenOffice Basic, every method of every supported interface is called directly at the object without querying for the appropriate interface, a control with the name TextField1 can be obtained from a dialog object oDialog simply by:

  oControl = oDialog.getControl("TextField1")

See OpenOffice.org Basic for additional information. The hierarchy between a dialog and its controls can be seen in the dialog model com.sun.star.awt.UnoControlDialogModel, which is a container for control models and therefore supports the com.sun.star.container.XNameContainer interface. A control model is obtained from a dialog model by:

  oDialogModel = oDialog.getModel()
  oControlModel = oDialogModel.getByName("TextField1")

or shorter:

  oControlModel = oDialog.Model.TextField1

The model of a control is also returned by the getModel() method of the control. In short notation:

  oControlModel = oControl.Model
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages