Sophie

Sophie

distrib > Mandriva > 10.2 > i586 > media > contrib > by-pkgid > 6338fb0a19fe7b6baeca7897c46a9ee3 > files > 68

knoda-0.7.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>The various actions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="The knoda scripting tutorial"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="The knoda scripting tutorial"
HREF="index.html"><LINK
REL="NEXT"
TITLE="General object methods- the class hk_visible"
HREF="chapter2.html"><META
HTTP-EQUIV="Content-Style-Type"
CONTENT="text/css"><LINK
REL="stylesheet"
HREF="common/kde-common.css"
TYPE="text/css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=iso-8859-1"><META
HTTP-EQUIV="Content-Language"
CONTENT="en"><LINK
REL="stylesheet"
HREF="common/kde-localised.css"
TYPE="text/css"
TITLE="KDE-English"><LINK
REL="stylesheet"
HREF="common/kde-default.css"
TYPE="text/css"
TITLE="KDE-Default"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#AA0000"
VLINK="#AA0055"
ALINK="#AA0000"
STYLE="font-family: sans-serif;"
><DIV
CLASS="logoheader"
><A
HREF="http://www.kde.org/"
></A
></DIV
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The knoda scripting tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="index.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="chapter2.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="CHAPTER1"
></A
>Chapter 1. The various actions</H1
><P
>Each object in a form has its own programmable actions.  General actions are
<UL
><LI
STYLE="list-style-type: disc"
><P
>On click: script that will be executed when a mouse click on this object occurs</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>On doubleclick: script that will be executed when a mouse doubleclick on this object occurs</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>On open: script that will be executed when the form is created or put into viewmode</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>On close: script that will be executed when the form is closed or put into designmode</P
></LI
></UL
>
Let's write a 'hello world' program.  Create a new form and add a button.  Select the button and click on the 'On click'-actionbutton
in the property editor.  Now add the following program into the program editor
<DIV
CLASS="EXAMPLE"
><HR><A
NAME="AEN34"
></A
><P
><B
>Example 1-1. Hello world-program</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>   1&nbsp;hk_this.show_warningmessage("Hello world")
   2&nbsp;</PRE
></TD
></TR
></TABLE
><HR></DIV
>
Now close the window and change to viewmode.  When you push the button you will see a dialog window with "Hello world".</P
><P
>The global variable <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>hk_this</I
></SPAN
> is set from hk_classes and represents the current object, in this case the button.
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>show_warningmessage()</I
></SPAN
> is a method of this object, that allows you to display a string in a GUI independent way (as knoda is a KDE application
it will be displayed as  a KDE window but if you start it within a command line program it will be displayed on the standard output).
<DIV
CLASS="IMPORTANT"
><TABLE
CLASS="IMPORTANT"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="common/important.png"
HSPACE="5"
ALT="Important"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>Other GUI-independent ways for user interaction are
<UL
><LI
STYLE="list-style-type: disc"
><P
>show_warningmessage(message); displays 'message'</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>bool show_yesnodialog(message, bool default_value); displays 'message' and returns true if you answer 'yes'.  The
parameter 'default_value' is used for conevience to preselect 'yes' or 'no' in dialog boxes</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_string show_stringvaluedialog(text); displays 'text' as a question and returns your response</P
></LI
></UL
></P
></TD
></TR
></TABLE
></DIV
></P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="chapter2.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>The knoda scripting tutorial</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>General object methods- the class hk_visible</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>