referencing custom views

In my project I have a custom view but it is not in any kind of window, but it can still hold UI elements and such. There is a text filed inside my custom view but when I try and get the text from it I get an error that says

Heres the code:

set gt_input to contents of text field "gt_search" of view "view"
	display dialog gt_input

Any help wud be lovely:/


Are you kidding me? You post at 8 in the morning, before many of us are even awake, and then come back and bump the post barely an hour later? Perhaps you could give us all a chance to replenish our caffeine levels and tend to our responsibilities before we sit down to save your world. After this show of blatantly selfish impatience, I wouldn’t help you regardless of how easy the solution was.

not 8 in the morning where i live jobu, sorry dude, it was 11:30 where im from, then i bumped 1 hour later, cud have waited longer for the bump i suppose, just anxious because i can barely start my program without knowing this…ive googled everything i cud find plus i searched everywhere on these forums. I can’t find any example AS Studio apps that use it, so excuse me for not being the guru you are, its just frustrating that I can barely start my new program because of this stupid roadblock

anyone? I think the reason it’s complicated is because its not a custom view embedded in a window

The view in question is Matt Gemmell’s MAAttachedWindow found here.

I have tried everything I can think of.

have you tried it without the “of view”…?
try with the normal “of window”…

sorry never used this before

yes, because my app actually does not have a window. It’s a menu bar application and when you click the menu icon the custom view drops down.

are you sure you have named the view correctly? I really have no idea.

(PS.this menu bar thing sounds really cool, if you want to share that would be cool :wink: )

It’s just a modified version of the example from this thread:

It’s modified so the MAAttached window appears upon clicking the icon

wow, i think i stumped you guys :wink:

Is your “set” statement inside a “tell … end tell” block referencing a datasource or some such. If so this may be the cause.

Try moving the set statement outside any “tell … end tell” blocks.


Nope, not in any kind of tell block, this is my whole program so far lol, as you can see I can’t really start anything until I can reference the custom view :stuck_out_tongue: By the way the custom view is a subclass of NS View if that helps.

-- Halo 3 Menu Stats.applescript
-- Halo 3 Menu Stats

--  Created by Collin Henderson on 03/03/08.
--  Copyright 2008 __MyCompanyName__. All rights reserved.

on launched theObject
	call method "showMenuIcon" of class "Menulet"
end launched

on idle theObject
	--blah blah
end idle

on activated theObject
end activated

on awake from nib theObject
	(*Add your script here.*)
end awake from nib

on action theObject
	if the name of theObject = "gt_search" then
	end if
end action
on get_gamertag()
	set gt_input to contents of text field "gt_search" of view "main"
	display dialog gt_input
end get_gamertag

maybe it’s a problem with the way the Ob-C gets the view? I don’t know Ob-C but is it copying the contents of your view as appose to just displaying it?
I had a fullscreen Ob-C script that made windows stretch to fit the screen but it just took the contents of the window and made a new one - this broke all as links

just an idea :wink:

I’m in the same boat as you, I have no Obj-C knowledge, thats why I probably need Dominik, or jobu (who refused to help me now), and I havent seem Dom in a while :frowning:

Does Bruce Phillips know any Obj-C? I’m really eager to get this app started! :stuck_out_tongue:

Individual views do not lend themselves well to AS usage in this way. Views alone do not initialize as you would expect, and never call their awake from nib handler unless they are in a window. So, I would recommend making a window with all of your stuff in it, and make your view the window’s content view. Then, at launch-time you can get the content view of the window, save a reference to it in a persistent variable, and use that. After the following code executes, you can use ‘SuperDuperView’ anywhere in your code to access your view programmatically.

property SuperDuperView : null

on launched theObject --> Connected to your application object
	set SuperDuperView to (content view of window "ExtraSpecialWindow")
end launched

ah! sheer genius! I’m glad you came through jobu, thank you for your time:D

I know you found the answer but if there is any chance you could share this that would be great :smiley:

Check out this link


ok, i don’t understand part of this because now the attached window that drops down has nothing inside it.
How do I copy everything in the window in to my custom view?

anyone know how?