Gtk::Button
Gtk::Buttonクラス
一般的にGtk::Buttonウィジェットは、ボタンが押下されたら呼び出されるような関数を関連付けるために使用します。いろいろなシグナルとその使い方については以降で簡単に説明します。
Gtk::Buttonウィジットは有効な子ウィジェットをいくつかもつことができます。つまり、一番標準的なGtk::Widgetをもつことができます。その一番よく利用される子ウィジェットはGtk::Labelです。
クラスメソッド
Gtk::Button.new
-
Gtk::Buttonウィジェットを生成します。
- 戻り値:新たに作成されたGtk::Buttonウィジェット
Gtk::Button.new(text, use_underline = true)
-
指定したテキストをもつGtk::Labelを子ウィジェットとしてGtk::Buttonウィジェットを生成します。
- text:Gtk::Labelに指定するテキスト
- use_underline:これがtrueでラベル中の文字の前にアンダースコアがついた場合、文字に下線が引かれます。もしリテラルのアンダースコア文字をラベル中で使用したいならば'__'(二つのアンダースコア)を用いて下さい。最初の下線装飾された文字はニーモニックと呼ばれるキーボードアクセラレータとして登録され、Altキーとその文字を同時に押すと"activate"シグナルが発行されます。
- 戻り値:新たに生成されたGtk::Buttonウィジェット
Gtk::Button.new(stock_id)
-
ストックアイテム(Gtk::Stockの定数)から画像やテキストを含む新たなGtk::Buttonを生成します。ストックアイテムの例としては、Gtk::Stock::OKやGtk::Stock::APPLYなどがあります。
- 戻り値:新たに生成されたGtk::Buttonウィジェット
インスタンスメソッド
pressed
-
自身に'pressed'シグナルを発行します
- 戻り値:self
released
- 自身に'released'シグナルを発行します
clicked
- 自身に'clicked'シグナルを発行します
enter
- 自身に'enter'シグナルを発行します
leave
- 自身に'leave'シグナルを発行します
relief
-
Returns the current relief style of the given Gtk::Button.
- Returns: The current GtkReliefStyle
relief=(newstyle)
-
Sets the relief style of the edges of the given Gtk::Button widget. Three styles exist, Gtk::RELIEF_NORMAL, Gtk::RELIEF_HALF, Gtk::RELIEF_NONE. The default style is, as one can guess, Gtk::RELIEF_NORMAL.
- newstyle: The GtkReliefStyle as described above.
- Returns: newstyle
set_relief(newstyle)
-
Same as Gtk::Button#relief=.
- newstyle: The GtkReliefStyle.
- Returns: self
label
-
Fetches the text from the label of the button, as set by Gtk::Button#label=. If the label text has not been set the return value will be nil. This will be the case if you create an empty button with Gtk::Button.new to use as a container.
- Returns: The text of the label widget.
label=(text)
-
Sets the text of the label of the button to str. This text is also used to select the stock item if Gtk::Button#use_stock= is used.
This will also clear any previously set labels.
- text: a string for the label text, a constant of Gtk::Stock for the stock item.
- Returns: text
set_label(text)
-
Same as Gtk::Button#label=.
- text: a string for the label text, a constant of Gtk::Stock for the stock item.
- Returns: self
use_stock?
- Returns whether the button label is a stock item.
use_stock=(use_stock)
-
If true, the label set on the button is used as a stock id to select the stock item for the button.
- use_stock: true if the button should use a stock item
- Returns: use_stock
set_use_stock(use_stock)
-
Same as Gtk::Button#use_stock=.
- use_stock: true if the button should use a stock item
- Returns: self
use_underline?
-
Returns whether an embedded underline in the button label indicates a mnemonic. See Gtk::Button#use_underline=.
- Returns: true if an embedded underline in the button label indicates the mnemonic accelerator keys.
use_underline=(use_underline)
-
If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.
- use_underline: true if underlines in the text indicate mnemonics
- Returns: use_underline
set_use_underline(use_underline)
-
Same as Gtk::Button#use_underline=.
- use_underline: true if underlines in the text indicate mnemonics
- Returns: self
alignment()
- 要編集
alignment=()
- 要編集
set_alignment()
- 要編集
image_position=()
- 要編集
set_image_position()
- 要編集
image_position()
- 要編集
yalign=()
- 要編集
set_yalign()
- 要編集
yalign()
- 要編集
xalign=()
- 要編集
set_xalign()
- 要編集
xalign()
- 要編集
focus_on_click=()
- 要編集
set_focus_on_click()
- 要編集
focus_on_click?()
- 要編集
image=()
- 要編集
set_image()
- 要編集
image()
- 要編集
activate()
- 要編集
プロパティ
label: String (Read/Write)
- Text of the label widget inside the button, if the button contains a label widget
relief: Integer (Read/Write)
- The border relief style
use-stock: true or false (Read/Write)
- If set, the label is used to pick a stock item instead of being displayed
use-underline: true or false (Read/Write)
- If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key
image-position:
- 要編集
yalign:
- 要編集
xalign:
- 要編集
focus-on-click:
- 要編集
image:
- 要編集
シグナル
activate: self
-
- self: Gtk::Button
clicked: self
-
- self: Gtk::Button
enter: self
-
- self: Gtk::Button
leave: self
-
- self: Gtk::Button
pressed: self
-
- self: Gtk::Button
released: self
-
- self: Gtk::Button
キーワード:
参照:[Gtk::Bin] [gtk2-tut-widget-overview] [Ruby/GTK Object Hierarchy] [Gtk::ToolItem] [Hello Worldの詳細] [Gtk::OptionMenu] [Gtk::Widget] [Gtk::Object] [Gdk::Window] [Gtk::Button] [Gtk::FontButton] [Gtk::Toolbar] [Ruby/GTK] [Gtk::RC] [Gtk::Container] [Gtk::FileSelection] [Gtk] [Gtk::ToggleButton] [Gtk::ColorButton] [Gtk::ColorSelectionDialog] [gtk2-tut-button] [Gtk::Label] [Gtk::CheckButton] [Gtk::RadioButton] [Gtk::FontSelectionDialog] [tips_toolbar] [Gtk::Expander] [ウインドウ]