comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » WIDGET ID FINDING FUNCTION
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
WIDGET ID FINDING FUNCTION [message #41050] Thu, 23 September 2004 18:42 Go to previous message
algosat is currently offline  algosat
Messages: 7
Registered: September 2004
Junior Member
Im not sure if I am allowed to actually post code here but anyhoo.

The following code is a function for finding widget ids of realized
widgets. Very handy as you dont have to carry around a pointer or
what-not to all of your pop-up windows you get it on demand.

Cheers
Andrew

FUNCTION FIND_WID, UNAME, NOMSG=NOMSG
; NAME:
; FIND_WID
; PURPOSE:
; To find the widget ID of the widget with uname, where uname is a
string
; passed in by the user.
; CATEGORY:
; Widget Utility
; CALLING SEQUENCE:
; RESULT=FIND_WID(UNAME)
; KEYWORDS:
; NOMSG: Use this keyword to to suppress dialog_messge pop-ups
; INPUTS:
; UNAME: A string with the user name of the widget whose ID is sought.
; OUTPUTS:
; The widget ID, if found, of the widget with the user name uname.
; If no widget ID is found a zero is returned to the user.
; RESTRICTIONS:
; The widget must be realized, and managed by xmanager
; EXAMPLE:
;1) you have 2 popups open and you want to use the set
; routine on 1 based on the state in the other, and you are
; in your TLB event handler.
;
; test_id=find_wid('state_widg')
; if test_id ne 0 then popup_set,test_id,state
;
;2) you are using a CW that is a second popup from the main
; TLB, and you have told xmanager that the main TLB
; event handler is to be used. So unless you have passed the
; state information, or a pointer to it, from the tlb->CW->TLB event
handler
; you will have lost the tlb id(well I always did), and hence access
; to the state info. So now you just do the following
;
; test_id=find_wid('main_tlb_uname_or_state_widget_uname')
; if test_id ne 0 then
widget_control,(test_id,/child),get_uvalue=state
;
; The above assumes you are using the first child widget uvalue
; to store the state info.
;
; MODIFICATION HISTORY:
; Written by: Andrew P. Rodger, September 24 2004
test_ids=widget_info(/managed)
;if only one result make sure its not zero
if (n_elements(test_ids) eq 1) then begin
if (test_ids eq 0) then begin
IF NOT KEYWORD_SET(NOMSG) THEN mess=dialog_message('No IDL
managed Widgets are running!',/error)
ret=0L
endif else begin
id=widget_info(test_ids,find_by_uname=uname)
if id eq 0 then begin
IF NOT KEYWORD_SET(NOMSG) THEN mess=dialog_message('No
widgets with the uname '+uname+' could be found',/error)
ret=0L
endif else begin
ret=long(id)
endelse
endelse
endif else begin
;see what windows are opened
ids=lonarr(n_elements(test_ids))
for i=0,n_elements(test_ids)-1 do begin
ids[i]=widget_info(test_ids[i],find_by_uname=uname)
endfor
nz=where(ids ne 0,count)
if (count gt 0) then begin
ret=long(ids[nz[0]]) ;this assumes that only one value is
going to be found
;who knows maby there are more: put in
warning
endif else begin
IF NOT KEYWORD_SET(NOMSG) THEN mess=dialog_message('No
widgets with the uname '+uname+' could be found',/error)
ret=0L
endelse
endelse
return,ret
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Composition structure
Next Topic: Creating HDF files

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 21:34:45 PDT 2025

Total time taken to generate the page: 1.27779 seconds