_guihelper.MessageBox

Default message box and dialog box

Title Default message box and dialog box
Author(s) LiXizhi
Date 2005/10, revised 2008.5.8
File script/ide/MessageBox.lua

Description

Member Functions

_guihelper.MessageBox

---------------------------------------------------------------
 message box (top level)
---------------------------------------------------------------

 the dialog background to used. if nil, it will be the default container background. 
_guihelper.MessageBox_BG = nil;
 how a message box is poped up. if nil, it is just displayed as a top level window. 
 If 1, it will gradually grey out the background and pops up with an animation. 
 If 2, it will grey out the background and pops up WITHOUT animations. 
_guihelper.MessageBox_PopupStyle = 1;

 Specifies constants defining which buttons to display on a MessageBox. 
_guihelper.MessageBoxButtons = {
   --The message box contains Abort, Retry, and Ignore buttons.  
   AbortRetryIgnore = 1, 
   --  The message box contains an OK button.  
   OK = 2, 
   -- The message box contains OK and Cancel buttons.  
   OKCancel = 3,
   -- The message box contains Retry and Cancel buttons.  
   RetryCancel = 4, 
   -- The message box contains Yes and No buttons.  
   YesNo = 5, 
   -- The message box contains Yes, No, and Cancel buttons.  
   YesNoCancel = 6,
   -- The message box contains no buttons at all. This is useful when displaying system generated message sequence
   -- Used in Aquarius login procedure
   Nothing = 7,
};

 Specifies identifiers to indicate the return value of a dialog box. 
_guihelper.DialogResult = {
   -- The dialog box return value is Abort (usually sent from a button labeled Abort).  
   Abort = 1,
   -- The dialog box return value is Cancel (usually sent from a button labeled Cancel).  
   Cancel = 2,
   -- The dialog box return value is Ignore (usually sent from a button labeled Ignore).  
   Ignore = 3, 
   -- The dialog box return value is No (usually sent from a button labeled No).  
   No = 4,

   -- Nothing is returned from the dialog box. This means that the modal dialog continues running.  
   None = 5,
   -- The dialog box return value is OK (usually sent from a button labeled OK).  
   OK = 6,
   -- The dialog box return value is Retry (usually sent from a button labeled Retry).  
   Retry = 7,
   -- The dialog box return value is Yes (usually sent from a button labeled Yes).  
   Yes = 8,
};

 Specifies constants defining which information to display. 
_guihelper.MessageBoxIcon = {
   -- The message box contains a symbol consisting of a lowercase letter i in a circle.  
   Asterisk = 1,
   -- The message box contains a symbol consisting of white X in a circle with a red background.  
   Error = 2,
   -- The message box contains a symbol consisting of an exclamation point in a triangle with a yellow background.  
   Exclamation = 3,
   -- The message box contains a symbol consisting of a white X in a circle with a red background.  
   Hand = 4,
   -- The message box contains a symbol consisting of a lowercase letter i in a circle.  
   Information = 5,
   -- The message box contain no symbols.  
   None = 6,
   -- The message box contains a symbol consisting of a question mark in a circle.  
   Question = 7,
   -- The message box contains a symbol consisting of white X in a circle with a red background.  
   Stop = 8,
   -- The message box contains a symbol consisting of an exclamation point in a triangle with a yellow background.  
   Warning = 9,
}
;

[[display a simple message box. Contents in previous displayed box will be appended to the new one

  • param content : string: the text to be displayed
  • param MsgBoxClick :_CallBack: [optional] string or function or nil; the script or function to be executed when user clicked OK or Yes. if it is a function, the first input will be _guihelper.DialogResult
  • param buttons : [optional] type of _guihelper.MessageBoxButtons
  • param icon : [optional] type of _guihelper.MessageBoxIcon
]]

syntax

function _guihelper.MessageBox(content,MsgBoxClick_CallBack, buttons, icon)

parameters

content string: the text to be displayed
MsgBoxClick  
CallBack  
buttons [optional] type of _guihelper.MessageBoxButtons
icon  

_guihelper.CloseMessageBox

close the messagebox slightly.

syntax

function _guihelper.CloseMessageBox()

_guihelper.OnMessageBoxClick

message box call back.

syntax

function _guihelper.OnMessageBoxClick(dialogResult)

parameters

dialogResult  

_guihelper.ShowDialogBox


dialog box (top level)

[[ display a top level dialog. Use windows.dialog for advanced dialog. this function is only for displaying a very simple (usually databinding) dialog control.

  • param title : string of title text or nil.
  • param x :,y,width, height: position and size of the client area of the dialog. if x,y is nil, it is displayed at the center of the screen.
  • param ShowUI :_func: function (_parent) end. this function is called to create UIs in the dialog but excluding the OK|cancel buttons. UI created in it will be automatically destroyed when dialog closes.
  • param OnClick :_CallBack: [optional] function (dialogResult) end or the function name string. The first input will be _guihelper.DialogResult.This function will be called when the dialog returns but before UI is destoryed. If function returns true, the dialog will be closed; otherwise dialog is not closed.
  • param buttons :; [optional] type of _guihelper.MessageBoxButtons
e.g. function SomeFunctionToCreateUIToGetherData() local package = CreatePackage({text="鏈懡鍚嶈祫婧愬寘"}); local bindingContext = commonlib.BindingContext:new(); bindingContext:AddBinding(package, "text", "AssetManager.NewAsset#packageName", commonlib.Binding.ControlTypes.ParaUI_editbox, "text") bindingContext:AddBinding(package, "icon", "AssetManager.NewAsset#textBoxIconPath", commonlib.Binding.ControlTypes.ParaUI_editbox, "text") bindingContext:AddBinding(package, "Category", "AssetManager.comboBoxCategory", commonlib.Binding.ControlTypes.IDE_dropdownlistbox, "text") bindingContext:AddBinding(package, "bDisplayInMainBar", "AssetManager.checkBoxShowInMainbar", commonlib.Binding.ControlTypes.IDE_checkbox, "value")

_guihelper.ShowDialogBox("Add a new package", nil, nil, 263, 114, function(_parent) _this = CreateUIObject("container", "AssetManager.NewAsset", "_fi", 0,0,0,0) _this.background = ""; _parent:AddChild(_this); _parent = _this;

_this = CreateUIObject("editbox", "packageName", "_mt", 85, 3, 3, 23) _parent:AddChild(_this);

_this = CreateUIObject("editbox", "textBoxIconPath", "_mt", 85, 58, 3, 23) _parent:AddChild(_this);

NPL.load("(gl)script/ide/dropdownlistbox.lua"); local ctl = CommonCtrl.dropdownlistbox:new{ name = "AssetManager.comboBoxCategory", alignment = "_mt", left = 85, top = 32, width = 3, height = 22, dropdownheight = 106, parent = _parent, text = "", items = {"Creations.BCS.doors", "Creations.BCS.windows", "Creations.Normals.Trees", }, }; ctl:Show();

NPL.load("(gl)script/ide/CheckBox.lua"); local ctl = CommonCtrl.checkbox:new{ name = "AssetManager.checkBoxShowInMainbar", alignment = "_lt", left = 3, top = 91, width = 166, height = 18, parent = _parent, isChecked = false, text = "娣诲姞鍒版垜鐨勫垱浣滃伐鍏锋爮", }; ctl:Show();

bindingContext:UpdateDataToControls(); end, function(dialogResult) if(dialogResult == _guihelper.DialogResult.OK) then bindingContext:UpdateControlsToData(); -- add to package list and update UI controls. AddPackage(package); end return true; end) end ]]

syntax

function _guihelper.ShowDialogBox(title, x,y,width, height, ShowUI_func,OnClick_CallBack, buttons)

parameters

title string of title text or nil.
x  
y  
width  
height  
ShowUI _func: function (_parent) end. this function is called to create UIs in the dialog but excluding the OK cancel buttons. UI created in it will be automatically destroyed when dialog closes.
func  
OnClick  
CallBack  
| buttons | ; [optional] type of _guihelper.MessageBoxButtons e.g. function SomeFunctionToCreateUIToGetherData() local package = CreatePackage({text="鏈懡鍚嶈祫婧愬寘"}); local bindingContext = commonlib.BindingContext:new(); bindingContext:AddBinding(package, "text", "AssetManager.NewAsset#packageName", commonlib.Binding.ControlTypes.ParaUI_editbox, "text") bindingContext:AddBinding(package, "icon", "AssetManager.NewAsset#textBoxIconPath", commonlib.Binding.ControlTypes.ParaUI_editbox, "text") bindingContext:AddBinding(package, "Category", "AssetManager.comboBoxCategory", commonlib.Binding.ControlTypes.IDE_dropdownlistbox, "text") bindingContext:AddBinding(package, "bDisplayInMainBar", "AssetManager.checkBoxShowInMainbar", commonlib.Binding.ControlTypes.IDE_checkbox, "value")

_guihelper.ShowDialogBox("Add a new package", nil, nil, 263, 114, function(_parent) _this = CreateUIObject("container", "AssetManager.NewAsset", "_fi", 0,0,0,0) _this.background = ""; _parent:AddChild(_this); _parent = _this;

_this = CreateUIObject("editbox", "packageName", "_mt", 85, 3, 3, 23) _parent:AddChild(_this);

_this = CreateUIObject("editbox", "textBoxIconPath", "_mt", 85, 58, 3, 23) _parent:AddChild(_this);

NPL.load("(gl)script/ide/dropdownlistbox.lua"); local ctl = CommonCtrl.dropdownlistbox:new{ name = "AssetManager.comboBoxCategory", alignment = "_mt", left = 85, top = 32, width = 3, height = 22, dropdownheight = 106, parent = _parent, text = "", items = {"Creations.BCS.doors", "Creations.BCS.windows", "Creations.Normals.Trees", }, }; ctl:Show();

NPL.load("(gl)script/ide/CheckBox.lua"); local ctl = CommonCtrl.checkbox:new{ name = "AssetManager.checkBoxShowInMainbar", alignment = "_lt", left = 3, top = 91, width = 166, height = 18, parent = _parent, isChecked = false, text = "娣诲姞鍒版垜鐨勫垱浣滃伐鍏锋爮", }; ctl:Show();

bindingContext:UpdateDataToControls(); end, function(dialogResult) if(dialogResult == _guihelper.DialogResult.OK) then bindingContext:UpdateControlsToData(); -- add to package list and update UI controls. AddPackage(package); end return true; end) end ]] |

_guihelper.OnDialogBoxClick

dialog box call back.

syntax

function _guihelper.OnDialogBoxClick(dialogResult)

parameters

dialogResult  


This topic: Main > NPL > MessageBox
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback