.TH wxButton 3erl "wx 2.2.2.1" "wxWidgets team." "Erlang Module Definition" .SH NAME wxButton \- Functions for wxButton class .SH DESCRIPTION .LP A button is a control that contains a text string, and is one of the most common elements of a GUI\&. .LP It may be placed on a \fIwxDialog\fR\& or on a \fIwxPanel\fR\& panel, or indeed on almost any other window\&. .LP By default, i\&.e\&. if none of the alignment styles are specified, the label is centered both horizontally and vertically\&. If the button has both a label and a bitmap, the alignment styles above specify the location of the rectangle combining both the label and the bitmap and the bitmap position set with \fIwxButton::SetBitmapPosition()\fR\& (not implemented in wx) defines the relative position of the bitmap with respect to the label (however currently non-default alignment combinations are not implemented on all platforms)\&. .LP Since version 2\&.9\&.1 \fIwxButton\fR\& supports showing both text and an image (currently only when using wxMSW, wxGTK or wxOSX/Cocoa ports), see \fISetBitmap()\fR\& (not implemented in wx) and \fIsetBitmapLabel/2\fR\&, \fIsetBitmapDisabled/2\fR\& &c methods\&. In the previous wxWidgets versions this functionality was only available in (the now trivial) \fIwxBitmapButton\fR\& class which was only capable of showing an image without text\&. .LP A button may have either a single image for all states or different images for the following states (different images are not currently supported under macOS where the normal image is used for all states): .LP All of the bitmaps must be of the same size and the normal bitmap must be set first (to a valid bitmap), before setting any other ones\&. Also, if the size of the bitmaps is changed later, you need to change the size of the normal bitmap before setting any other bitmaps with the new size (and you do need to reset all of them as their original values can be lost when the normal bitmap size changes)\&. .LP The position of the image inside the button be configured using \fISetBitmapPosition()\fR\& (not implemented in wx)\&. By default the image is on the left of the text\&. .LP Please also notice that GTK+ uses a global setting called \fIgtk-button-images\fR\& to determine if the images should be shown in the buttons at all\&. If it is off (which is the case in e\&.g\&. Gnome 2\&.28 by default), no images will be shown, consistently with the native behaviour\&. .LP Styles .LP This class supports the following styles: .LP See: \fIwxBitmapButton\fR\& .LP This class is derived (and can use functions) from: \fIwxControl\fR\& \fIwxWindow\fR\& \fIwxEvtHandler\fR\& .LP wxWidgets docs: wxButton .SH "EVENTS" .LP Event types emitted from this class: \fIcommand_button_clicked\fR\& .SH DATA TYPES .nf \fBwxButton()\fR\& = wx:wx_object() .br .fi .SH EXPORTS .LP .nf .B new() -> wxButton() .br .fi .br .RS .LP Default ctor\&. .RE .LP .nf .B new(Parent, Id) -> wxButton() .br .fi .br .RS .LP Types: .RS 3 Parent = wxWindow:wxWindow() .br Id = integer() .br .RE .RE .LP .nf .B new(Parent, Id, Options :: [Option]) -> wxButton() .br .fi .br .RS .LP Types: .RS 3 Parent = wxWindow:wxWindow() .br Id = integer() .br Option = .br {label, unicode:chardata()} | .br {pos, {X :: integer(), Y :: integer()}} | .br {size, {W :: integer(), H :: integer()}} | .br {style, integer()} | .br {validator, wx:wx_object()} .br .RE .RE .RS .LP Constructor, creating and showing a button\&. .LP The preferred way to create standard buttons is to use default value of \fIlabel\fR\&\&. If no label is supplied and \fIid\fR\& is one of standard IDs from this list, a standard label will be used\&. In other words, if you use a predefined \fIwxID_XXX\fR\& constant, just omit the label completely rather than specifying it\&. In particular, help buttons (the ones with \fIid\fR\& of \fIwxID_HELP\fR\&) under macOS can\&'t display any label at all and while \fIwxButton\fR\& will detect if the standard "Help" label is used and ignore it, using any other label will prevent the button from correctly appearing as a help button and so should be avoided\&. .LP In addition to that, the button will be decorated with stock icons under GTK+ 2\&. .LP See: \fIcreate/4\fR\&, \fIwxValidator\fR\& (not implemented in wx) .RE .LP .nf .B create(This, Parent, Id) -> boolean() .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br Parent = wxWindow:wxWindow() .br Id = integer() .br .RE .RE .LP .nf .B create(This, Parent, Id, Options :: [Option]) -> boolean() .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br Parent = wxWindow:wxWindow() .br Id = integer() .br Option = .br {label, unicode:chardata()} | .br {pos, {X :: integer(), Y :: integer()}} | .br {size, {W :: integer(), H :: integer()}} | .br {style, integer()} | .br {validator, wx:wx_object()} .br .RE .RE .RS .LP Button creation function for two-step creation\&. .LP For more details, see \fInew/3\fR\&\&. .RE .LP .nf .B getDefaultSize() -> {W :: integer(), H :: integer()} .br .fi .br .RS .LP Returns the default size for the buttons\&. .LP It is advised to make all the dialog buttons of the same size and this function allows retrieving the (platform, and current font dependent) size which should be the best suited for this\&. .LP The optional \fIwin\fR\& argument is new since wxWidgets 3\&.1\&.3 and allows to get a per-monitor DPI specific size\&. .RE .LP .nf .B getDefaultSize(Win) -> {W :: integer(), H :: integer()} .br .fi .br .RS .LP Types: .RS 3 Win = wxWindow:wxWindow() .br .RE .RE .RS .RE .LP .nf .B setDefault(This) -> wxWindow:wxWindow() .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br .RE .RE .RS .LP This sets the button to be the default item in its top-level window (e\&.g\&. .LP the panel or the dialog box containing it)\&. .LP As normal, pressing return causes the default button to be depressed when the return key is pressed\&. .LP See also \fIwxWindow:setFocus/1\fR\& which sets the keyboard focus for windows and text panel items, and \fIwxTopLevelWindow::SetDefaultItem()\fR\& (not implemented in wx)\&. .LP Remark: Under Windows, only dialog box buttons respond to this function\&. .LP Return: the old default item (possibly NULL) .RE .LP .nf .B setLabel(This, Label) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br Label = unicode:chardata() .br .RE .RE .RS .LP Sets the string label for the button\&. .RE .LP .nf .B getBitmapDisabled(This) -> wxBitmap:wxBitmap() .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br .RE .RE .RS .LP Returns the bitmap for the disabled state, which may be invalid\&. .LP See: \fIsetBitmapDisabled/2\fR\& .LP Since: 2\&.9\&.1 (available in \fIwxBitmapButton\fR\& only in previous versions) .RE .LP .nf .B getBitmapFocus(This) -> wxBitmap:wxBitmap() .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br .RE .RE .RS .LP Returns the bitmap for the focused state, which may be invalid\&. .LP See: \fIsetBitmapFocus/2\fR\& .LP Since: 2\&.9\&.1 (available in \fIwxBitmapButton\fR\& only in previous versions) .RE .LP .nf .B getBitmapLabel(This) -> wxBitmap:wxBitmap() .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br .RE .RE .RS .LP Returns the bitmap for the normal state\&. .LP This is exactly the same as \fIGetBitmap()\fR\& (not implemented in wx) but uses a name backwards-compatible with \fIwxBitmapButton\fR\&\&. .LP See: \fISetBitmap()\fR\& (not implemented in wx), \fIsetBitmapLabel/2\fR\& .LP Since: 2\&.9\&.1 (available in \fIwxBitmapButton\fR\& only in previous versions) .RE .LP .nf .B setBitmapDisabled(This, Bitmap) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br Bitmap = wxBitmap:wxBitmap() .br .RE .RE .RS .LP Sets the bitmap for the disabled button appearance\&. .LP If \fIbitmap\fR\& is invalid, the disabled bitmap is set to the automatically generated greyed out version of the normal bitmap, i\&.e\&. the same bitmap as is used by default if this method is not called at all\&. Use \fISetBitmap()\fR\& (not implemented in wx) with an invalid bitmap to remove the bitmap completely (for all states)\&. .LP See: \fIgetBitmapDisabled/1\fR\&, \fIsetBitmapLabel/2\fR\&, \fISetBitmapPressed()\fR\& (not implemented in wx), \fIsetBitmapFocus/2\fR\& .LP Since: 2\&.9\&.1 (available in \fIwxBitmapButton\fR\& only in previous versions) .RE .LP .nf .B setBitmapFocus(This, Bitmap) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br Bitmap = wxBitmap:wxBitmap() .br .RE .RE .RS .LP Sets the bitmap for the button appearance when it has the keyboard focus\&. .LP If \fIbitmap\fR\& is invalid, the normal bitmap will be used in the focused state\&. .LP See: \fIgetBitmapFocus/1\fR\&, \fIsetBitmapLabel/2\fR\&, \fISetBitmapPressed()\fR\& (not implemented in wx), \fIsetBitmapDisabled/2\fR\& .LP Since: 2\&.9\&.1 (available in \fIwxBitmapButton\fR\& only in previous versions) .RE .LP .nf .B setBitmapLabel(This, Bitmap) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxButton() .br Bitmap = wxBitmap:wxBitmap() .br .RE .RE .RS .LP Sets the bitmap label for the button\&. .LP Remark: This is the bitmap used for the unselected state, and for all other states if no other bitmaps are provided\&. .LP See: \fISetBitmap()\fR\& (not implemented in wx), \fIgetBitmapLabel/1\fR\& .LP Since: 2\&.9\&.1 (available in \fIwxBitmapButton\fR\& only in previous versions) .RE .LP .nf .B destroy(This :: wxButton()) -> ok .br .fi .br .RS .LP Destroys the object\&. .RE