Matlab的GUI回调函数.docx

上传人:小飞机 文档编号:3161221 上传时间:2023-03-11 格式:DOCX 页数:5 大小:38.03KB
返回 下载 相关 举报
Matlab的GUI回调函数.docx_第1页
第1页 / 共5页
Matlab的GUI回调函数.docx_第2页
第2页 / 共5页
Matlab的GUI回调函数.docx_第3页
第3页 / 共5页
Matlab的GUI回调函数.docx_第4页
第4页 / 共5页
Matlab的GUI回调函数.docx_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《Matlab的GUI回调函数.docx》由会员分享,可在线阅读,更多相关《Matlab的GUI回调函数.docx(5页珍藏版)》请在三一办公上搜索。

1、Matlab的GUI回调函数Kinds of Callbacks The following table lists the callback properties that are available, their triggering events, and the components to which they apply. Note:User interface controls include push buttons, sliders, radio buttons, check boxes, editable text boxes, static text boxes, list

2、 boxes, and toggle buttons. They are sometimes referred to as uicontrols. 1 GUIDE Callback Arguments All callbacks in a GUIDE-generated GUI code file have the following standard input arguments: hObject Handle of the object, e.g., the GUI component, for which the callback was triggered. For a button

3、 group SelectionChangeFcn callback, hObject is the handle of the selected radio button or toggle button. eventdata Sequences of events triggered by user actions such as table selections emitted by a component in the form of a MATLAB struct (or an empty matrix for components that do not generate even

4、tdata) handles A MATLAB struct that contains the handles of all the objects in the GUI, and may also contain application-defined data. See handles Structure for information about this structure. Object Handle The first argument is the handle of the component issuing the callback. Use it to obtain re

5、levant properties that the callback code uses and change them as necessary. For example, theText = get(hObject,String); places the String property (which might be the contents of static text or name of a button) into the local variable theText. You can change the property by setting it, for example

6、set(hObject,String,date) This particular code changes the text of the object to display the current date. Event Data Event data is a stream of data describing user gestures, such as key presses, scroll wheel movements, and mouse drags. The auto-generated callbacks of GUIDE GUIs can access event data

7、 for Handle Graphics and uicontrol and uitable object callbacks. The following ones receive event data when triggered: CellEditCallback in a uitable CellSelectionCallback in a uitable KeyPressFcn in uicontrols and figures KeyReleaseFcn in a figure SelectionChangeFcn in a uibuttongroup WindowKeyPress

8、Fcn in a figure or any of its child objects WindowKeyReleaseFcn in a figure or any of its child objects WindowScrollWheelFcn in a figure Event data is passed to GUIDE-generated callbacks as the second of three standard arguments. For components that issue no event data the argument is empty. For tho

9、se that provide event data, the argument contains a structure, which varies in composition according to the component that generates it and the type of event. For example, the event data for a key-press provides information on the key(s) currently being pressed. Here is a GUIDE-generated KeyPressFcn

10、 callback template: % - Executes on key press with focus on checkbox1 and none of its controls. function checkbox1_KeyPressFcn(hObject, eventdata, handles) 2 % hObject handle to checkbox1 (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was press

11、ed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) The eventdata structure passed in has three fields, identifying the Character

12、being pressed (such as =), the key Modifier (such as control), and the Key name (spelled out, such as equals). Components that provide event data use different structures with event-specific field names to pass data. Callbacks with event data usually are repeatedly issued as long as the event persis

13、ts or sometimes at the beginning of an event and thereafter only when its values change. Learn how callbacks use event data by looking at the GUIDE uitable example GUI to Interactively Explore Data in a Table (GUIDE) and the programmatic uitable example GUI that Displays and Graphs Tabular Data. han

14、dles Structure GUIDE creates a handles structure that contains the handles of all the objects in the figure. For a GUI that contains an edit text, a panel, a pop-up menu, and a push button, the handles structure originally looks similar to this. GUIDE uses each components Tag property to name the st

15、ructure element for its handle. handles = figure1: 160.0011 edit1: 9.0020 uipanel1: 8.0017 popupmenu1: 7.0018 pushbutton1: 161.0011 output: 160.0011 GUIDE creates and maintains the handles structure as GUI data. It is passed as an input argument to all callbacks and enables a GUIs callbacks to share

16、 property values and application data. For information about GUI data, see Ways to Manage Data in a GUIDE GUI and the guidata reference page. For information about adding fields to the handles structure and instructions for correctly saving the structure, see Adding Fields to the handles Structure and Changing GUI Data in a Code File Generated by GUIDE. 3

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号