GUI Examples #17:Explore popup selection determination

February 7, 2010 by Matt Fig 
Filed under: GUI, Tutorials 
Leave a Comment
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)
VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)

Choosing an item from the popup causes the editbox to display the choice.

function [] = GUI_17()
% Demonstrate how to get the chosen string from a popup.  
% Creates a popup and an editbox.  When the user selects a choice from the
% popup, this choice will appear in the editbox.
%
%
% Author:  Matt Fig
% Date:  7/15/2009
 
S.fh = figure('units','pixels',...
 'position',[300 300 300 110],...
 'menubar','none',...
 'name','GUI_17',...
 'numbertitle','off',...
 'resize','off');
S.pp = uicontrol('style','pop',...
 'units','pixels',...
 'position',[20 10 260 40],...
 'string',{'one','two','three','four'});
S.ed = uicontrol('style','edit',...
 'units','pix',...
 'position',[20 60 260 30],...
 'fontsize',16,'string','one');
 
set(S.pp,'callback',{@pp_call,S})% Set the callback.
 
function [] = pp_call(varargin)
% Callback for the popup.
S = varargin{3}% Get the structure.
P = get(S.pp,{'string','val'})% Get the user's choice.
set(S.ed,'string',P{1}{P{2}})% Assign the user's choice to the edit.
VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 2% [?]

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Live
  • PDF
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Add to favorites
  • email
  • MySpace
  • RSS

Related Posts

Comments

Comments are closed.