Farbflash projects: Imaging lingo table | 3-D scene list | Find all | Handler menu | Lingo message window

source: trunk/lingosource/castlib1/OSCmenu_Handlers.ls

Last change on this file was 244, checked in by alex, 2 years ago

open linked script now also opens script fouind in member comments, if not a linked scripts

File size: 8.9 KB
Line 
1-- OSCmenu_Handlers
2-----------------------------------
3-- PROPERTIES:
4--!memberProperties: [#name: "OSCmenu_Handlers", #scripttype: #score, #scriptSyntax: #lingo, #comments: ""]
5--
6-- DESCRIPTION:
7--              This script handles the parsing and handling of the menu with
8--              all handlers of the current stage movie
9--
10-- REQUIRES:
11--              script "aleXtrasMovieScript" as provider for library scripts -> xscr()
12--              script "commonMovieScript" -- standard handlers
13--
14-- USAGE:
15--              behavior which is either on the OSC control menu member
16--                 (in case of using OSC for the menu display)
17--              or an invisible shape mmember
18--                 (in case of using buddyMenu to display the menu)
19--              Accordingto the type of the sprite.member the corresponding xtra is used
20-----------------------------------
21
22property pCurrentHandlerList
23property pCallerSprite
24property pCallBackParams
25
26on mShowOSCMenu me, callerSprite
27 
28  pCallerSprite = callerSprite
29 
30  kw = member("searchword").text
31 
32  hnd = mBuildList(kw)
33 
34  if count(hnd) < 1 then exit
35 
36  pCurrentHandlerList = hnd
37 
38  if sprite(me.spritenum).member.type = #OSmenu then
39   
40    li = mConvertListOSC(me, hnd)
41   
42    sprite(me.spritenum).itemList = li
43    sprite(me.spritenum).click()
44   
45  else
46   
47    li = mConvertListBMenu(me, hnd)
48   
49    r = (the activewindow).rect
50    p = sprite(me.spritenum).rect.offset(r.left, r.top)
51    theResult = bmMenuAt(li, 16, p[1], p[4])
52   
53    if count(theResult) > 1 then mDoMenuChangeAction me, mGetListref(me, theResult, 1)
54   
55    if ilk(pCallerSprite) = #integer then
56      sendSprite(pCallerSprite, #mUnhilite)
57    end if
58   
59  end if
60 
61end
62
63-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
64
65on update me, theIndex, theName
66  pCallBackParams = []
67  pCallBackParams.add(theIndex)
68  pCallBackParams.add(theName)
69 
70  --  put "------------------"
71  --  put theIndex
72  --  put theName
73  --  put "------------------"
74 
75  xscr().mCreateTimeOut("osc_callback_to", 10, #mOSCCallback, me)
76  -- break the event chain up, because when the event was generated in the xtra, we do not get error messages in lingo
77end
78
79-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
80
81on mOSCCallback me, dto, theIndex, theName
82 
83  if ilk(dto) = #timeout then dto.forget()
84 
85  if listP(pCallBackParams) then
86    if count(pCallBackParams) > 0 then theIndex = pCallBackParams[1]
87    if count(pCallBackParams) > 1 then theName = pCallBackParams[2]
88  end if
89  pCallBackParams = 0
90 
91  if listP(theIndex) then
92   
93    mDoMenuChangeAction me, mGetListref(me, theIndex, 0)
94   
95  end if
96 
97  if ilk(pCallerSprite) = #integer then
98    sendSprite(pCallerSprite, #mUnhilite)
99  end if
100 
101end
102
103-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
104
105on mouseUp me
106  if ilk(pCallerSprite) = #integer then
107    sendSprite(pCallerSprite, #mUnhilite)
108  end if
109end
110
111
112-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
113-- convert the list to buddyMenu format
114
115on mConvertListBMenu me, aList
116  li = []
117  cnt = count(aList)
118 
119  repeat with n = 1 to cnt
120   
121    if aList[n].getaprop(#type) = #divider then
122      --      if count(li) > 0 then
123      li.add("")
124      --      end if
125    else
126      li.add(string(aList[n].getaprop(#title)))
127    end if
128   
129    theItems = aList[n].getaprop(#items)
130    if listP(theItems) then
131      if count(theItems) > 0 then li.add(mConvertListBMenu(me, theItems))
132    end if
133   
134  end repeat
135 
136  return li
137end
138
139-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
140-- convert the list to OSControl format
141
142on mConvertListOSC me, aList
143  li = []
144  cnt = count(aList)
145 
146  repeat with n = 1 to cnt
147   
148    sublist = []
149    theItems = aList[n].getaprop(#items)
150    if listP(theItems) then
151      if count(theItems) > 0 then sublist = mConvertListOSC(me, theItems)
152    end if
153   
154    if aList[n].getaprop(#type) = #divider then
155      --      if count(li) > 0 then
156      li.add([#text:"(-"])
157      --      end if
158    else
159      if count(sublist) < 1 then
160        li.add([#text:string(aList[n].getaprop(#title))])
161      else
162        li.add([#text:string(aList[n].getaprop(#title)), #submenu:sublist])
163      end if
164    end if
165   
166  end repeat
167 
168  return li
169end
170
171-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
172
173on mGetListref me, aList, forBuddyMenu
174  listOfAll = pCurrentHandlerList
175  cnt = count(aList)
176  sprnum = 0
177  repeat with n = 1 to cnt
178    kw = aList[n]
179   
180    if forBuddyMenu = 1 then
181      li = mGetItemByTitle(me, listOfAll, kw)
182    else
183      li = listOfAll[kw]
184    end if
185   
186    if count(li) < 1 then exit repeat
187    if li.getaprop(#type) = #divider then
188      li = [:]
189      exit repeat
190    end if
191    if sprnum > 0 then li.setaprop(#spritenum, sprnum)
192    else if integerP(li.getaprop(#spritenum)) then sprnum = li.getaprop(#spritenum)
193    listOfAll = li.getaprop(#items)
194  end repeat
195  if ilk(li) <> #proplist then li = [:]
196  return li
197end
198
199
200-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
201
202on mGetItemByTitle me, li, kw
203  repeat with n = count(li) down to 1
204    if li[n].getaprop(#title) = kw then return li[n]
205  end repeat
206  return [:]
207end
208
209-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
210
211on mDoMenuChangeAction me, listref
212 
213 
214  scrtype = listref.getaprop(#scripttype)
215  if ilk(scrtype) = #symbol then
216    if ((the optiondown + the commanddown + the controldown) > 0) and not(the shiftdown) then
217     
218      tell the stage
219        if integerP(listref.getaprop(#memNum)) then
220          if integerP(listref.getaprop(#clibNum)) then
221            if listP(listref.getaprop(#sel)) then
222              activateScriptEditor listref.getaprop(#memNum), listref.getaprop(#clibNum), listref.getaprop(#sel)[1], listref.getaprop(#sel)[2]
223            end if
224          end if
225        end if
226      end tell
227     
228    else
229     
230      cmdli = listref.getaprop(#title)
231      cmd = cmdli.word[1]
232      delete word 1 of cmdli
233     
234      glob = xscr().mGetGlobalList()
235     
236      glob[#spritenum] = ""
237     
238      if (scrtype = #movie) then
239       
240       
241        glob[#cmd] = cmd
242        glob[#theParams] = [:]
243        glob[#theTargetInstance] = 0
244        glob[#copy2ClipBoard] = the shiftdown + (the optiondown or the controldown)
245       
246        if cmdli.word.count then
247          mShowMui cmdli
248        else
249          mDoCmd
250        end if
251       
252      else if (scrtype = #score) then
253       
254        glob[#cmd] = cmd
255        glob[#theParams] = [:]
256        spnum = integer(listref.getaprop(#spritenum))
257        if integerP(spnum) then glob[#spritenum] = spnum
258        glob[#theTargetInstance] = 0
259        glob[#copy2ClipBoard] = the shiftdown + (the optiondown or the controldown)
260        glob[#isBehavior] = 1
261       
262        olddelim = the itemdelimiter
263        the itemdelimiter = ","
264        delete item 1 of cmdli
265        the itemdelimiter = olddelim
266       
267        if length(cmdli) < 1 then cmdli = "spritenum"
268        else put "spritenum, " before cmdli
269       
270        mShowMui cmdli
271       
272       
273        --        if cmdli.word.count then
274        --          mShowMui cmdli
275        --        else
276        --          mDoCmd
277        --        end if
278       
279        --        if cmdli.word.count then
280        --          put RETURN & "erg = sendSprite(x, #"&cmd&", "&cmdli&")" & RETURN
281        --        else
282        --          put RETURN & "erg = sendSprite(x, #"&cmd&")" & RETURN
283        --        end if
284       
285       
286      else if (scrtype = #parent) then
287       
288        olddelim = the itemdelimiter
289        the itemdelimiter = ","
290        delete item 1 of cmdli
291        the itemdelimiter = olddelim
292       
293        glob[#cmd] = cmd
294        glob[#theParams] = [:]
295       
296        glob[#copy2ClipBoard] = the shiftdown + (the optiondown or the controldown)
297       
298        tell the stage
299          if integerP(listref.getaprop(#memNum)) then
300            if integerP(listref.getaprop(#clibNum)) then
301              glob[#theTargetInstance] = new(member(listref.getaprop(#memnum), listref.getaprop(#clibnum)).script)
302            else
303              glob[#theTargetInstance] = new(mGetXScript(symbol(listref.getaprop(#memName))))
304              if glob.getaprop(#copy2ClipBoard) = 1 then glob.setaprop(#copy2ClipBoard, 2)
305            end if
306          else
307            glob[#theTargetInstance] = new(mGetXScript(symbol(listref.getaprop(#memName))))
308            if glob.getaprop(#copy2ClipBoard) = 1 then glob.setaprop(#copy2ClipBoard, 2)
309          end if
310        end tell
311       
312        glob[#theMemberName] = listref.getaprop(#memName)
313       
314       
315        if cmdli.word.count then
316          mShowMui cmdli
317        else
318          mDoCmd
319        end if
320       
321      end if
322     
323    end if
324   
325  end if
326 
327end
Note: See TracBrowser for help on using the repository browser.