元編程參考文件

圖形介面應用

37 個節點

本頁內容 37

圖形介面應用

函數

此節點沒有文件說明。

簽名
圖形介面應用() -> GUI Application
GUIApplication GUIApplication()

返回

圖形介面應用GUI Application
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

新增按鈕

函數

Add a button. Pressing it delivers its intent to the Clicked callback.

簽名
新增按鈕
    GUI Application: GUI Application
    文字: 文字
    意圖: 文字
    種類: Button Kind
    名稱: 文字
void AddButton(
    GUIApplication GUI Application,
    string text,
    string intent,
    ButtonKind kind = ButtonKind.Secondary,
    string name)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
文字文字—The caption.
意圖文字—What pressing it means. The caption, unless the graph says otherwise - so a keypad's "7" means "7" with nothing more said, and a button captioned "Go" can mean "Start Run".
種類Button Kind次要How it looks, which says how important it is.
名稱文字—A name, so the button can be reached afterwards. The intent, unless the graph says otherwise.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

新增分隔線

函數

Add a hairline rule.

簽名
新增分隔線(GUI Application: GUI Application)
void AddDivider(GUIApplication GUI Application)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

新增標籤

函數

Add a line of text.

簽名
新增標籤
    GUI Application: GUI Application
    文字: 文字
    名稱: 文字
    角色: Label Role
    對齊方式: Text Alignment
void AddLabel(
    GUIApplication GUI Application,
    string text = "",
    string name,
    LabelRole role = LabelRole.Body,
    TextAlignment alignment = TextAlignment.Left)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
文字文字—What it says.
名稱文字—A name, so the text can be changed afterwards with Set Text.
角色Label Role正文How prominent it is.
對齊方式Text Alignment左對齊Where the text sits in the room it has.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

新增間隔

函數

Add empty room: a fixed number of pixels, or with no size, whatever room is free.

簽名
新增間隔(GUI Application: GUI Application, 大小: 數字)
void AddSpacer(GUIApplication GUI Application, double size = 0)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
大小數字0Pixels, or 0 to take the free room in a column or row.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

新增文字方塊

函數

Add a line of text the person can edit. Read it back with Get Text.

簽名
新增文字方塊
    GUI Application: GUI Application
    名稱: 文字
    文字: 文字
    佔位文字: 文字
    意圖: 文字
void AddTextBox(
    GUIApplication GUI Application,
    string name,
    string text = "",
    string placeholder = "",
    string intent)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
名稱文字—A name; a text box exists to be read, so it always has one.
文字文字—What it starts out saying.
佔位文字文字—A hint shown while it is empty.
意圖文字—在框中按 Enter 的含義,像按下按鈕一樣交給“已點選”——讓文字方塊和它的按鈕用同一個意圖,Enter 和按鈕就做同一件事,只寫一次。留空時,按 Enter 不通知任何東西。
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

開始卡片

函數

Open a card: a raised surface with an optional heading, holding its children in a column.

簽名
開始卡片
    GUI Application: GUI Application
    標題: 文字
    副標題: 文字
    名稱: 文字
void BeginCard(
    GUIApplication GUI Application,
    string title,
    string subtitle,
    string name)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
標題文字—The heading, or nothing for a plain surface.
副標題文字—A second line under the heading.
名稱文字—A name, if the graph will need to reach the card afterwards.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

開始列

函數

Open a column: everything added until the matching End stacks top to bottom.

簽名
開始列(GUI Application: GUI Application, 間距: 數字, 名稱: 文字)
void BeginColumn(
    GUIApplication GUI Application,
    double spacing = 10,
    string name)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
間距數字10Gap between the children, in pixels.
名稱文字—A name, if the graph will need to reach the column afterwards.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

開始網格

函數

Open a grid of equal cells. Children fill it row by row, in the order they are added, unless one is
placed explicitly with GUIApplication.PlaceInGrid.

簽名
開始網格
    GUI Application: GUI Application
    列數: 整數
    行數: 整數
    間距: 數字
    名稱: 文字
void BeginGrid(
    GUIApplication GUI Application,
    int columns = 2,
    int rows = 0,
    double spacing = 8,
    string name)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
列數整數2How many cells across.
行數整數0How many cells down, or 0 for as many as the children need.
間距數字8Gap between cells, in pixels.
名稱文字—A name, if the graph will need to reach the grid afterwards.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

開始行

函數

Open a row: everything added until the matching End runs left to right.

簽名
開始行(GUI Application: GUI Application, 間距: 數字, 名稱: 文字)
void BeginRow(
    GUIApplication GUI Application,
    double spacing = 8,
    string name)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
間距數字8Gap between the children, in pixels.
名稱文字—A name, if the graph will need to reach the row afterwards.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

關閉

函數

Ask to stop. Whatever is running the application decides what that means - a windowed host closes its
window, an offline driver stops pumping.

簽名
關閉(GUI Application: GUI Application)
void Close(GUIApplication GUI Application)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

結束

函數

Close the innermost open container. Every Begin needs one.

簽名
結束(GUI Application: GUI Application)
void End(GUIApplication GUI Application)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

期望的視窗大小

函數

How big a window to open. A host offers a default before anything runs; the entry callback may say
otherwise, and the host honours whatever the answer is when it opens a window.

簽名
期望的視窗大小(GUI Application: GUI Application) -> Size
Size DesiredWindowSize(GUIApplication GUI Application)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—

返回

結果Size
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

期望的視窗標題

函數

The window's title.

簽名
期望的視窗標題(GUI Application: GUI Application) -> 文字
string DesiredWindowTitle(GUIApplication GUI Application)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—

返回

結果文字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

取得已用時間

函數

Time the current frame represents, in milliseconds.

簽名
取得已用時間(GUI Application: GUI Application) -> 數字
double GetElapsedTime(GUIApplication GUI Application)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—

返回

結果數字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

取得文字

函數

What a named element says right now - for a text box, what the person has typed.

簽名
取得文字(GUI Application: GUI Application, 名稱: 文字) -> 文字
string GetText(GUIApplication GUI Application, string name)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
名稱文字—

返回

結果文字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

是否有該元素

函數

Whether the screen has an element of this name.

簽名
是否有該元素 -> 真否
    GUI Application: GUI Application
    名稱: 文字
bool HasElement(GUIApplication GUI Application, string name)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
名稱文字—

返回

結果真否
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

放入網格

函數

Put the element added most recently in a particular cell of the grid it is in.

簽名
放入網格
    GUI Application: GUI Application
    行: 整數
    列: 整數
    跨行數: 整數
    跨列數: 整數
void PlaceInGrid(
    GUIApplication GUI Application,
    int row,
    int column,
    int rowSpan = 1,
    int columnSpan = 1)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
行整數—The row, from 0 at the top.
列整數—The column, from 0 at the left.
跨行數整數1How many rows it covers.
跨列數整數1How many columns it covers.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

按下

函數

Act on an intent as if a button meaning it had been pressed - what a keyboard shortcut does.

簽名
按下(GUI Application: GUI Application, 意圖: 文字)
void Press(GUIApplication GUI Application, string intent)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
意圖文字—What to act on.

備註

The reason a keyboard arm does not have to repeat a click arm: a graph reads a key, decides which of
its own keys it stands for, and presses that. The press is indistinguishable from a real one - the
same GUIApplication.Clicked, the same GUIApplication.WasClicked for the rest of the frame - because it
goes through the same door. An intent no button carries is allowed: a key may mean something the
screen has no button for.

Calling this from inside GUIApplication.Clicked with the intent being handled would not return; that
is the ordinary hazard of a callback that calls itself, and the answer is the ordinary one.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

重新構建

函數

Ask for the screen to be described again: Build runs afresh before the next frame, and the widgets
are made anew from what it says.

簽名
重新構建(GUI Application: GUI Application)
void Rebuild(GUIApplication GUI Application)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—

備註

Requested rather than done here, because the host is in the middle of a frame - possibly inside the
very button handler asking for this - and the widgets it is routing input through must not be replaced
under it. Nothing is lost by waiting one frame; a rebuild is for a screen whose SHAPE changes, and
text that merely changes goes through GUIApplication.SetText without one.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定啟用

函數

Whether a named element can be used. A disabled button draws dimmed and delivers nothing.

簽名
設定啟用
    GUI Application: GUI Application
    名稱: 文字
    啟用: 真否
void SetEnabled(
    GUIApplication GUI Application,
    string name,
    bool enabled = true)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
名稱文字—
啟用真否True
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定內邊距

函數

Set the room inside the edge of the container opened most recently.

簽名
設定內邊距(GUI Application: GUI Application, 內邊距: 數字)
void SetPadding(
    GUIApplication GUI Application,
    double padding = 14)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
內邊距數字14Pixels on every side.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定大小

函數

Fix the size of the element added most recently. Leave a dimension NaN to keep it free.

簽名
設定大小
    GUI Application: GUI Application
    寬度: 數字
    高度: 數字
void SetSize(
    GUIApplication GUI Application,
    double width = double.NaN,
    double height = double.NaN)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
寬度數字NaNPixels, or NaN for "as wide as it needs and may".
高度數字NaNPixels, or NaN for "as tall as it needs and may".
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定拉伸

函數

Give the element added most recently a share of the free room in its column or row.

簽名
設定拉伸(GUI Application: GUI Application, 權重: 數字)
void SetStretch(
    GUIApplication GUI Application,
    double weight = 1)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
權重數字1Its share, against the shares of its siblings. 1 for an equal share.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定文字

函數

Change what a named element says: a label's text, a button's caption, a text box's content.

簽名
設定文字
    GUI Application: GUI Application
    名稱: 文字
    文字: 文字
void SetText(
    GUIApplication GUI Application,
    string name,
    string text = "")

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
名稱文字—
文字文字—
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定文字自適應

函數

Draw the text of the element added most recently as large as fits it, growing and shrinking with the room it is given - or, for a container, the text of every label and button inside it.

簽名
設定文字自適應
    GUI Application: GUI Application
    自適應: 真否
    邊距: 數字
void SetTextFit(
    GUIApplication GUI Application,
    bool fit = true,
    double margin = 0.2)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
自適應真否TrueWhether to fit the text; false goes back to the size its role has.
邊距數字0.2How much room to leave round the text, as a share of the box's shorter side on each side: 0.2 leaves a fifth above and below.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定可見

函數

Whether a named element is shown at all. A hidden element takes no room.

簽名
設定可見
    GUI Application: GUI Application
    名稱: 文字
    可見: 真否
void SetVisible(
    GUIApplication GUI Application,
    string name,
    bool visible = true)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
名稱文字—
可見真否True
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定視窗大小

函數

Set the size the window opens at.

簽名
設定視窗大小
    GUI Application: GUI Application
    寬度: 數字
    高度: 數字
void SetWindowSize(
    GUIApplication GUI Application,
    double width = 480,
    double height = 640)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
寬度數字480
高度數字640
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

設定視窗標題

函數

Set the window's title.

簽名
設定視窗標題(GUI Application: GUI Application, 標題: 文字)
void SetWindowTitle(
    GUIApplication GUI Application,
    string title = "Divooka")

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
標題文字Divooka
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

顯示通知

函數

Show a brief notice in the corner of the window.

簽名
顯示通知(GUI Application: GUI Application, 訊息: 文字)
void ShowNotice(GUIApplication GUI Application, string message)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
訊息文字—

備註

Queued rather than shown, because this package has nothing to show it with; the host drains the queue
each frame. A message posted from Start, before there is a window, is shown on the first frame.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

是否被點選

函數

Whether a button meaning this was pressed during the current frame.

簽名
是否被點選(GUI Application: GUI Application, 意圖: 文字) -> 真否
bool WasClicked(GUIApplication GUI Application, string intent)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
意圖文字—

返回

結果真否

備註

The polling half of input, for an Update that would rather ask than be told. False outside a
frame and false for an intent nobody named: an unpressed button is the ordinary case.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

是否按下了鍵

函數

Whether this key was pressed during the current frame.

簽名
是否按下了鍵(GUI Application: GUI Application, 鍵: 文字) -> 真否
bool WasKeyPressed(GUIApplication GUI Application, string key)

參數

名稱型別預設值說明
GUI ApplicationGUI Application—
鍵文字—The key, as GUIApplication.KeyPressed describes it.

返回

結果真否

備註

The polling half of the keyboard, for an Update that would rather ask than be told.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

構建

事件

Describe the screen: open containers, add labels and buttons, close containers. Runs once when the
window is ready, and again whenever the graph asks to GUIApplication.Rebuild.

簽名
構建()
void Build()
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

已點選

事件

A button was pressed.

簽名
已點選(意圖: 文字)
void Clicked(string intent)

參數

名稱型別預設值說明
意圖文字—What the button MEANS - the intent it was added with, which is its caption unless the graph said otherwise.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

已按鍵

事件

A key was pressed.

簽名
已按鍵(鍵: 文字)
void KeyPressed(string key)

參數

名稱型別預設值說明
鍵文字—The key, as text. A key that types something arrives as what it typed - "7", ".", "+", "A" - and a key that types nothing arrives by name: "Enter", "Escape", "Backspace", "Tab", "Delete", "Left", "Right", "Up", "Down", "Home", "End", "Page Up", "Page Down", "Insert", "F1".."F12". See GUIApplication.NamedKeys.

備註

Text rather than a key enumeration, for two reasons. A graph compares text - that is what its Equals
and Choose nodes are for - and an enumeration would need a palette of its own before a document could
name a key. And what a key TYPES is the layout's answer, not the keycode's: the key beside
0 types . on one keyboard and , on another, and a calculator wants the former.
A key held down repeats as the platform repeats it, because that is what a person typing expects.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

啟動

事件

Divooka procedural program entry, equivalent to "Main" in many programming languages. Runs before the
window exists, which is where window size and title belong; the screen itself is described in
GUIApplication.Build.

簽名
啟動()
void Start()
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用

更新

事件

Called once per frame, after that frame's presses have been delivered.

簽名
更新(時間增量(毫秒): 數字)
void Update(double deltaTimeMilliseconds)

參數

名稱型別預設值說明
時間增量(毫秒)數字—Time elapsed since the previous frame.
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 狀態機狀態
宣告於
圖形介面應用
所屬包
圖形介面應用