Custom action on button click
#1
I'm now sitting for days and can't figure out if the following is possibel. I have a button in my custom dialog. If this button is clicked, a custom action of my dialog should be executed.

This is the Python code:

Code:
class XMLDialog(WindowXMLDialog):

    def __init__(self, xmlFilename, scriptPath, defaultSkin = None, forceFallback = None):
        WindowXMLDialog.__init__(self, xmlFilename, scriptPath, defaultSkin, forceFallback)

    def onAction(self, action):
        if not action.getId() == 107:
            self.log("Action received:" +str(action.getId()) + " " + str(action.getButtonCode()))

    def customAction(self):
        self.log("My custom action is executed.")

And the corresponding XML has a button as follows:

Code:
<control type="button" id="5005">
    <description>Custom Action</description>
    <posx>380</posx>
    <posy>110</posy>
    <width>100</width>
    <height>35</height>
    <label>Cancel</label>
    <align>center</align>
    <aligny>center</aligny>
    <onclick>customAction()</onclick>
</control>

Is this in someway possible? When I click on the button, no usable action (with the button id) is sent to onAction. Why not?
Reply
#2
Ha. The API documentation is not that clear. But there is a onClick function in the parent class (Window) which takes the control ID as parameter.
Reply

Logout Mark Read Team Forum Stats Members Help
Custom action on button click0