QT Class RadPushButton

 

Overview

The RadPushButton class implements a push button with a text label.

A RadPushButton is an option button that can be pressed by the user to indicate an option choice. Push buttons are typically used to represent features in an application that can be enabled without affecting others, but different types of behavior can be implemented depending upon the push button manager Lambda (see the setMgr method).

Push buttons in the IDE Debugger Tab

The Console tab contains two push buttons with labels of Clear and Run. These are used to clear the console pane and to execute Lisp commands on the Console. The Lisp source file Ais/Tutorial_IDE/ideMgr.sl contain the code which creates these two push button controls.

IDE Debugger Tab

new

Overview

The new function creates a new RadPushButton object and returns a pointer to the newly created object. The RadPushButton is one of the class key words accepted by the qt new: function. There can be many RadPushButton objects.

 

Syntax

(qt new: RadPushButton: buttonlabel buttonMgr)

Arguments

buttonlabelA string describing the push button.
buttonMgrThe push button manager lambda to manage the RadPushButton object.
ReturnsAlways returns a pointer to the newly created RadPushButton object.

The RadPushButton responds to only one event - the KeyPress event. The RadPushButton manager, if present, is invoked when the KeyPress event occurs. If the RadPushButton manager Lambda contains a member Lambda named "press", then the press Lambda will be invoked when the KeyPress event occurs; otherwise the RadPushButton manager Lambda itself will be invoked when the KeyPress event occurs. For example:

        ;; The RadPushButton manager may contain a press member and it may return a value to the calling program.
        (lambda (...) (defun press(...) (writeln "If I exist, I will be invoked on a KeyPress event") 0))
        ;; The RadPushButton manager may contain no press member and it may return a value to the calling program.
        (lambda (...) (writeln "There is no press member, So I will be invoked on a KeyPress event") 1)
        

 

Example1

(defun tabMgr(...) true) ;; Perform noop tab managment
(defun buttonMgr(...) (qt radPushButtonPtr setText: "Ouch") true) ;; Perform push button management
(qt mainWindow: setTitle: (append "My QT Push Button Demo")) ;; Set the main window title
(setq radPushButtonPtr (qt new: RadPushButton: "PressMe" buttonMgr)) ;; Create a new RadPushButton object labeled "Press"
(setq tabIndex (qt mainWindow: addTab: radPushButtonPtr "PushButton" tabMgr)) ;; Add a new push button to the main window
(qt mainWindow: maximize:) ;; Display the main window

delete

Overview

The delete function destroys a RadPushButton object and returns a null pointer.

 

Syntax

(qt delete: RadPushButtonPtr)

Arguments

radRadPushButtonPtrThe pointer to the RadPushButton object to be destroyed.
ReturnsAlways returns a null pointer.

 

Example1

(setq radPushButtonPtr (qt new: RadPushButton: "BLUE" Bluetextmgr)) ;; Create a RadPushButton object.
(setq radPushButtonPtr (qt delete: radPushButtonPtr)) ;; Destroy the RadPushButton object.

getText

Overview

The RadPushButton getText function gets the text contents of the display pane in the RadPushButton.

 

Syntax

(setq myTextPtr (qt radPushButtonPtr getText:))

Arguments

myTextPtr Always returns the push button text pointer

 

Example1

(defun tabMgr(...) true) ;; Perform noop tab managment
(defun buttonMgr(...) (if (= (qt radPushButtonPtr getText:) "PressMe") then (qt radPushButtonPtr setText: "Ouch") else (qt radPushButtonPtr setText: "PressMe"))
true)
(qt mainWindow: setTitle: (append "My QT Push Button Demo")) ;; Set the main window title
(setq radPushButtonPtr (qt new: RadPushButton: "PressMe" buttonMgr)) ;; Create a new RadPushButton object labeled "Press"
(setq tabIndex (qt mainWindow: addTab: radPushButtonPtr "PushButton" tabMgr)) ;; Add a new push button to the main window
(qt mainWindow: maximize:) ;; Display the main window

setMgr

Overview

The RadPushButton setMgr function sets a lisp function name to manage the behavior of a PushButton.

The RadPushButton responds to only one event - the KeyPress event. The RadPushButton manager, if present, is invoked when the KeyPress event occurs. If the RadPushButton manager Lambda contains a member Lambda named "press", then the press Lambda will be invoked when the KeyPress event occurs; otherwise the RadPushButton manager Lambda itself will be invoked when the KeyPress event occurs. For example:

        ;; The RadPushButton manager may contain a press member and it may return a value to the calling program.
        (lambda (...) (defun press(...) (writeln "If I exist, I will be invoked on a KeyPress event") 0))
        ;; The RadPushButton manager may contain no press member and it may return a value to the calling program.
        (lambda (...) (writeln "There is no press member, So I will be invoked on a KeyPress event") 1)
        

 

Syntax

(qt setMgr: mgrLambda)

Arguments

mgrLambda A name of a lambda function
true Always returns true

 

Example1

(defun tabMgr(...) true) ;; Perform noop tab managment
(defun buttonMgr(...) (if (= (qt radPushButtonPtr getText:) "PressMe") then (qt radPushButtonPtr setText: "Ouch") else (qt radPushButtonPtr setText: "PressMe"))
true)
(qt mainWindow: setTitle: (append "My QT Push Button Demo")) ;; Set the main window title
(setq radPushButtonPtr (qt new: RadPushButton: "PressMe" tabMgr)) ;; Oops we set the wrong manager
(qt radPushButtonPtr setMgr: buttonMgr) ;; Set the proper RadPushButton manager
(setq tabIndex (qt mainWindow: addTab: radPushButtonPtr "PushButton" tabMgr)) ;; Add a new push button to the main window
(qt mainWindow: maximize:) ;; Display the main window

setText

Overview

The RadPushButton setText function sets the text contents of the display pane in the RadPushButton.

 

Syntax

(qt radPushButtonPtr setText: buttonText)

Arguments

buttonText The new text to be set in the Push Button pane
return Always returns #void

 

Example1

(defun tabMgr(...) true) ;; Perform noop tab managment
(defun buttonMgr(...) (if (= (qt radPushButtonPtr getText:) "PressMe") then (qt radPushButtonPtr setText: "Ouch") else (qt radPushButtonPtr setText: "PressMe"))
true)
(qt mainWindow: setTitle: (append "My QT Push Button Demo")) ;; Set the main window title
(setq radPushButtonPtr (qt new: RadPushButton: "PressMe" buttonMgr)) ;; Create a new RadPushButton object labeled "Press"
(setq tabIndex (qt mainWindow: addTab: radPushButtonPtr "PushButton" tabMgr)) ;; Add a new push button to the main window
(qt mainWindow: maximize:) ;; Display the main window