von dp am 28.April 97 um 02:27:04:
From: "John C. Ware"
Subject: Re: Finally a question...length of field
To: Multiple recipients of list DIRECT-L
>
>
>>I currently just incrementally change the
>>field rect until the linecount property indictates it's wrapping (ie,
>>too narrow) and then back off a step and set the field rect to that
>>width which is passed to the popObject as the rect to use in the given
>>menu. This works well enough but it makes for an annoying burp in
>>popping the menu on. Any ideas?
>
>
Gosh, I hope I'm not oversimplifying this, but I actually DID this,
(popup MIAW), and I just put a return at the end of each line,
and used a field with adjust to fit and word wrap off, stuffed the text
in, checked the field size, resized to next evenly divisble by 16 width
then sized the window to fit. worked like a charm, and fast, faster then
system popups, (kept in ram, not disk hit, most popups load resource.
Here is the code that called into the popup windoid to track. It would handle
keyboard driven, (space to activate popup, arrows to move selection, return to
choose item), or mouse driven tracking.
on widgetPopupWindoidTrack piMemberRefEntry, piEntrySprite, piMemberRefPopup, pbMousing
--*-*-------------------------------------------------------------------------
-- Function
-- widgetPopupWindoidTrack piMemberRefEntry, piEntrySprite, piMemberRefPopup, pbMousing
--
-- Purpose
-- General purpose script to work with any popup with two text fields, one
-- to store the result, (what usually shows up on screen ), and one which contains
-- all of the popup items, (stored as a castmember of the appropriate width
-- with the correct drop shadow.
--
-- Requires PU.DIR to be running as a MIAW
-- Requires/assumes that the sprite channel of the popup is already puppeted,
-- and that the hilite channel is a bitmap type channel.
--
-- Entry
-- pass in the result/entry member, and the popup text member
-- pass in pbMousing to indicate whether this is a clickon based or keyboard based invocation
--
-- Exit
-- RETURNs the new value of the attached display, 0 if no change. Also updates contents
-- of the display, so can be treated as a boolean flag that the value has changed.
--
-- Globals Used
-- gi.PU.WinIndex - position of popup in window list
-- ks.Default - default text string
-- ks.PopupSpacer - text string, preceeding spaces before text of item
-- ks.SymbolCurrentState - etc.etc.
--
----------------------------------------------*/
-- hilight accompanying name sprite?
global gi.PU.WinIndex, ks.Default, ks.PopupSpacer
global ks.SymbolCurrentState
global gi.Widget.DotMemberRef, giWidgetTopSprite, giFocusIDSprite
global giPopTextHeight, kiFarOffScreen, gi.Widget.FocusMemberRef
global gi.Widget.PopupHiliteMemberRef, gi.Widget.PopupHiliteBottomMemberRef
-- toggle button appropriately
global gi.Widget.PopDownList.Down.MemberRef, gi.Widget.PopDownList.Up.MemberRef
global gi.Widget.PopDownList.Disabled.MemberRef
-- check if there is a tip window to draw into, if not, bail
if ( MIAWValid ( gi.PU.WinIndex ) ) then
if ( objectP ( piMemberRefPopup ) AND objectP ( piMemberRefEntry ) ) then
if ( ( the type of piMemberRefPopup = #Field ) AND ( the type of piMemberRefEntry = #Field ) ) then
-- initialize variables
set giPopTextHeight = lineheight ( piMemberRefPopup, 1 )
set tempLine = 0 -- default to nothing selected
-- set indicator in popup text, derives several values including current index
set llInfo = [] -- item 1 = number of items, item 2 = current value
-- put " piMemberRefEntry = " & piMemberRefEntry
-- put " piMemberRefPopup = " & piMemberRefPopup
widgetPopupSetIndicator ( piMemberRefEntry, piMemberRefPopup, llInfo )
set liNumItems = getAt ( llInfo, 1 )
set piCurrentValue = getAt ( llInfo, 2 )
-- calculate offset of popup above the location of the entry popup text
if ( piCurrentValue > 0 ) then
set ciPopOffsetV = giPopTextHeight * ( piCurrentValue )
else
set ciPopOffsetV = 0
end if
-- build the window
tell getAt ( the windowlist, gi.PU.WinIndex) to setText ( piMemberRefPopup )
-- calculate where to put window
set tempWindowOxOSizeRect = the rect of piMemberRefPopup -- size of popup
if ( NOT ( the member of sprite piEntrySprite = gi.Widget.PopDownList.Down.MemberRef ) ) then
set offsetH = the stageLeft + the left of sprite piEntrySprite + 1 -- works regardless of regpoint/type
else
set offsetH = the stageLeft + the right of sprite piEntrySprite -1 - the width of tempWindowOxOSizeRect
end if
if the type of the member of sprite piEntrySprite = #bitmap then -- always put button popups below, not next to
set offsetV = the stageTop + the bottom of sprite piEntrySprite
else
set offsetV = the stageTop + the bottom of sprite piEntrySprite - ciPopOffsetV
end if
set tempWindowSizeScreenRect = offset ( tempWindowOxOSizeRect, offsetH, offsetV )
-- now display it in new location
set the rect of getAt ( the windowlist, gi.PU.WinIndex ) to tempWindowSizeScreenRect
set the modal of getAt ( the windowlist, gi.PU.WinIndex ) to 1
-- now show it
tell getAt ( the windowlist, gi.PU.WinIndex) to hilite line piCurrentValue of field piMemberRefPopup
set piCurrentValue = 0
moveToFront getAt ( the windowlist, gi.PU.WinIndex)
-- now track as appropriate
if ( pbMousing ) then -- dragging hilite around, regular popup functionality
repeat while the mouseDown
set myMouseLoc = point ( the mouseH + the stageLeft, the mouseV + the stageTop )
if ( inside ( myMouseLoc, tempWindowSizeScreenRect ) ) then
set tempLine = integer ( ( ( ( getAt (myMouseLoc, 2 ) - the top of tempWindowSizeScreenRect)*1.0)/¬
giPopTextHeight) + 0.5)
if ( ( 0 tempLine ) then
tell getAt ( the windowlist, gi.PU.WinIndex) to hilite line the mouseLine of field piMemberRefPopup
set piCurrentValue = tempLine
else
-- correct line already hilited, do nothing
end if
else
tell getAt ( the windowlist, gi.PU.WinIndex) to set the hilite of field piMemberRefPopup = 0
set tempLine = 0
set piCurrentValue = 0
end if
else
tell getAt ( the windowlist, gi.PU.WinIndex) to set the hilite of field piMemberRefPopup = 0
set tempLine = 0
set piCurrentValue = 0
end if
end repeat
if ( tempLine > 0 ) then
repeat with counter = 1 to 3
tell getAt ( the windowlist, gi.PU.WinIndex) to hilite line tempLine of field piMemberRefPopup
tell getAt ( the windowlist, gi.PU.WinIndex) to updateStage
clockBriefDelay
tell getAt ( the windowlist, gi.PU.WinIndex) to set the hilite of field piMemberRefPopup = 0
tell getAt ( the windowlist, gi.PU.WinIndex) to updateStage
clockBriefDelay
end repeat
end if
else -- windows functionality, popup pops down, then waits for you to click on an item.
repeat while (NOT the mouseDown )
-- nothing
end repeat
tell getAt ( the windowlist, gi.PU.WinIndex) to dontpassevent
set myMouseLoc = point( the mouseH + the stageLeft, the mouseV + the stageTop)
if inside(myMouseLoc, tempWindowSizeScreenRect) then
set tempLine = integer ( ( ( ( getAt (myMouseLoc, 2 ) - the top of tempWindowSizeScreenRect)*1.0)/¬
giPopTextHeight) + 0.5)
repeat with counter = 1 to 3
tell getAt ( the windowlist, gi.PU.WinIndex) to hilite line tempLine of field piMemberRefPopup
tell getAt ( the windowlist, gi.PU.WinIndex) to updateStage
clockBriefDelay
tell getAt ( the windowlist, gi.PU.WinIndex) to set the hilite of field piMemberRefPopup = 0
tell getAt ( the windowlist, gi.PU.WinIndex) to updateStage
clockBriefDelay
end repeat
tell getAt ( the windowlist, gi.PU.WinIndex) to dontpassevent
else
-- close window, don't change data
set tempLine = 0
end if
end if
dontpassevent
-- close the window down
set the visible of getAt ( the windowlist, gi.PU.WinIndex) = 0
-- now, in either case, set the entry value and return the tempLine
if tempLine then
set tempLine = word 1 to ( the number of words in line tempLine of field piMemberRefPopup) ¬
of line tempLine of field piMemberRefPopup
if word 1 of tempLine = ks.SymbolCurrentState then delete word 1 of tempLine
-- strip out section dividers
if ( tempLine contains "---" ) then -- no change
set tempLine = 0
else
-- determine whether entry is a displayable popup or an editable text entry
if ( the border of piMemberRefEntry > 0 ) then
set the text of field piMemberRefEntry = ks.PopupSpacer & tempLine
else
set the text of field piMemberRefEntry = tempLine
end if
end if
end if
return tempLine
else
debugMessage "WARNING - WidgetPopupWindoidTrack called with bad members, " & piMemberRefEntry && piMemberRefPopup, 0
end if
else
debugMessage "WARNING - WidgetPopupWindoidTrack called with bad fields, " & piMemberRefEntry && piMemberRefPopup, 0
end if
else
debugMessage "WARNING - WidgetPopupWindoidTrack called with no PU. window", 0
end if
dontpassevent
end widgetPopupWindoidTrack
and heres a sample call into this routine
set bChanged = widgetPopupWindoidTrack (gi.AA.PopPrimitiveValueMember, ¬
gi.AA.ExpressionPopup.Sprite, gi.OA.PopSensorListMember, pbMousing)
---------
jcw = John C. Ware, Macromedian
for more info, uh, reply...
D. Plänitz