Re: setting tab stops in a document

2010-06-05 Thread Ross Carter
On Jun 5, 2010, at 1:09 AM, Boyd Collier wrote:

> In an application I'm working on, I read in plain text files containing data 
> to be analyzed.  This uses a slightly-modified version of MyDocument.m that 
> is produced as a result of starting a project with the template for 
> NSDocument architecture.  The modification that I made was to add a method 
> named updateView, which is called near the end of windowControllerDidLoadNib 
> and loadDataRepresentation: ofType:  
> 
> My reason for adding this method is to make the spacing of tabs something 
> that works well for the sort of data files being analyzed, which presume tabs 
> are used to separate values being analyzed.   Here's the code:
...
> [[textView textStorage] addAttributes:attrs range:NSMakeRange(0, [[[textView 
> textStorage] string] length])];


Couple of suggestions: 

1. Call NSTextView -shouldChangeTextInRange:replacementString: before modifying 
the textStorage, and call -didChangeText afterward.

2. Look at NSTextView -setDefaultParagraphStyle:.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: detecting touch and hold vs touch in UIButton

2010-06-05 Thread Scott Andrew
I believe the way to do this is to setup a timer on touchDown to fire once 
after X number of seconds. Your touchUp and touchCancelled should kill the 
timer if the timer is exists and is not invalidated. If you hit the timer you 
are being held. When the timer is hit you restart the timer again for the next 
check. 

Scott


On Jun 4, 2010, at 7:16 PM, Alejandro Marcos Aragón wrote:

> Hi all,
> 
> I've been trying to detect touch and hold vs touch on a subclass of UIButton. 
> I basically accomplished that by doing the following:
> 
> I first add the following when the button is created:
> 
> 
>   [button addTarget:self action:@selector(sourceSelected:)
>   forControlEvents:UIControlEventTouchUpInside];
>   [button addTarget:self action:@selector(sourceTouchDown:) 
>   forControlEvents:UIControlEventTouchDown];
> 
> Then in the functions:
> 
> - (void) sourceSelected:(UIButton*) sender {
> 
>   
>   // cancel request for extended meny
>   [NSObject cancelPreviousPerformRequestsWithTarget:self 
> selector:@selector(sourceSelectedExtended:) object:sender];
>   ...
> }
> 
> - (void) sourceTouchDown:(UIButton*) sender {
> 
>   // give time before performing action
>   [self performSelector:@selector(sourceSelectedExtended:) 
> withObject:sender afterDelay:0.5];  
> }
> 
> - (void) sourceSelectedExtended:(UIButton*) sender {
> 
>   // remove action from button
>   [sender removeTarget:self action:@selector(sourceSelected:) 
> forControlEvents:UIControlEventTouchUpInside];
>   ...
>   ...
>   // give time before performing action
>   [self performSelector:@selector(addSourceAction:) withObject:sender 
> afterDelay:1.];  
> 
> }
> 
> - (void) addSourceAction:(UIButton*)sender {
> 
>   // remove action from button
>   [sender addTarget:self action:@selector(sourceSelected:) 
> forControlEvents:UIControlEventTouchUpInside];
>   
> }
> 
> 
> 
> Now, this works fine, but then I thought there must be an easier (and 
> definitely more elegant) way to accomplish the same thing.
> 
> Can someone through me a line here?
> 
> Thank you all,
> 
> aa
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/scottandrew%40roadrunner.com
> 
> This email sent to scottand...@roadrunner.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: The Unadopted Protocol

2010-06-05 Thread Matt Neuburg
On or about 6/2/10 11:11 AM, thus spake "Greg Parker" :

> On Jun 2, 2010, at 8:57 AM, Matt Neuburg wrote:
>> So this appears to be a technique for implementing a highly informal
>> protocol. (The technique is: define a protocol, don't bother adopting it
>> anywhere, but send messages defined in that protocol to an id.)
> 
> Yep. When the compiler looks for a method declaration matching a message sent
> to `id`, it looks at every declaration encountered up to that point in the
> file.
> 
> That's comparable to the traditional way to create informal protocols: declare
> a category on NSObject, don't bother implementing it anywhere, and send
> messages declared in that category to other objects.
> 
> In general we discourage both of these now.

But in fact I see now that UIAlertView works exactly this way; its delegate
is typed as id, not as id . This explains why my class
never has to adopt UIAlertViewDelegate formally. Doubtless an alert view
with a delegate is *so* common that Apple felt it would drive the programmer
mad to have to adopt UIAlertViewDelegate formally all over the place.

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Focus and selection color of a NSTextView

2010-06-05 Thread Erick Pérez
HiL
I have this window with two NSTextView in it, and i changed the color
of the selected text's background to pink on one of the NSTextView and
when i click the other one it lost the focus and the color goes to
gray, is there anyway that maintin the colro pink no matter if the
NStextView has the focus or not???

Thxs

-- 
El derecho de expresar nuestros pensamientos tiene algún significado
tan sólo si somos capaces de tener pensamientos propios.
El miedo a la libertad, Erich Fromm
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


PDFSelection question

2010-06-05 Thread Matthew Weinstein
Dear programmers,
I think I must be missing some simple method in the api to do this, but, given 
a range of a PDFDocument string, how do I convert that to a selection? I found 
the PDFPage selection from range, but how do I find what pages a selection for 
the document string covers?

Thanks for any assistance.




Matthew Weinstein
Associate Professor of Science Education
Education Program
U.W. - Tacoma
253 692-4787

matth...@u.washington.edu

Campus Box: 358435
1900 Commerce Street
Tacoma, WA  98402-3100
Office:  (253) 692-4787
FAX: (253) 692-5612



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSData Question... could be a bit odd

2010-06-05 Thread Development
I have an NSData object I'm using because they are easier than buffers. 
What I need to do is have a backwards copy of the data in memory that I can 
quickly dump. The thing is I'm not entirely sure how I would go about getting 
the data in to a new object backwards. Any ideas?

Thanks

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Cross XIB references?

2010-06-05 Thread Jean-François Brouillet
Hi.

Consider the situation where I have a "root" ImageView in IB.
I specify the actual image I want it to hold by just filling/
selecting which of the existing images are already present in the
project, using the "Image" input box of the Image View Attributes
inspector.

Then I can just set the titleView outlet of some navigationItem
elsewhere in the same nib file, and voilà, my image is displayed
at runtime exactly where I want I, when I want it.

But now I create a second nib file for a second controller, and
I really would like to display the same image in the same kind
of setup.

Problem is: I haven't figured out whether it is possible at all
for nib file#2 to refer to any object inside nib file#1, hence
I have to either pay the memory cost of a duplicate object in
the second nib file, or forget about nib files entirely and do
the whole wiring by hand with code, which kind of defeats the
purpose of separate nib files in the first place.

So ... is there a way to refer to NIB1.objA from NIB2.objB ?

Bonus question: is it possible at all to refer to nib files
(while staying within IB) outside of the main project directory?
I tried variations on ./rsrc/mynib2 or rsrc/mynib2 in the NIB Name
input field to no avail ...

I plainly understand that I can spread my NIB files all over the
place (almost :-) if I go the coding route, but I'd rather do
everything I can in IB if that's possible ...

Any idea?

Thanks
--
JFB___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[iPhone] Preprocessing events sent to UITableView

2010-06-05 Thread WT
I need to hijack the set of touch events sent to a UITableView instance prior 
to allowing the table to process those events.

I have a custom UIView, of which the table view is a subview, and I override 
-hitTest:withEvent: there (in the custom view) to return self, thereby 
preventing the table from receiving those touches.

Since my custom view does not implement any of the four event-handling methods 
(-touchesBegan:withEvent:, etc), the view controller managing my custom view 
gets the touches, through the regular traversal of the responder chain.

There, in the view controller event-handling methods, I determine whether or 
not I need to consume the events. If not, I need to send them back to the table 
view for it to do its normal event handling (for instance, scrolling).

All of the above works fine, except...

... how do I send the touch events back to the table view?

I tried storing the actual result of the hit-test (I'm not going to assume it's 
the table view) in the custom view prior to returning self as the hit-view, 
then accessing that from the view controller that manages the custom view, and 
then invoking the four event-handling methods in the actual hit-view from 
within the corresponding methods in the view controller, but that didn't work. 
The table view still doesn't get the touches.

What's the recommended way of doing what I need to do?

Thanks in advance.
Wagner___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: setting tab stops in a document

2010-06-05 Thread Boyd Collier
Thanks, Ross and Paul, I've finally got things working the way I wanted.  
Here's what my code now looks like (in case someone else has a similar problem):

- (void)updateView {
[[self textView] setString:[self string]];  // replaced textView 
with [self textView]  6-8-06
NSTextView *myTextView = [self textView];
// code to set tab stops, as suggested by PGM   
int cnt;
int numStops = 200;
int tabInterval = 80;
NSTextTab *tabStop;
 
NSMutableDictionary *attrs = [[NSMutableDictionary alloc] init]; 
//attributes for attributed string of TextView
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] 
init];

[paraStyle setTabStops:[NSArray array]];   // clear all tab stops

// now put in tab stops at desired intervals
for (cnt = 0; cnt < numStops; cnt++) {
tabStop = [[NSTextTab alloc] initWithType:NSLeftTabStopType 
location:tabInterval*(cnt+1)];
[paraStyle addTabStop:tabStop];
[tabStop release];
}

/** ADDED CODE **/
NSMutableDictionary* typingAttributes = [[myTextView typingAttributes] 
mutableCopy];
[typingAttributes setObject:paraStyle 
forKey:NSParagraphStyleAttributeName];
[myTextView setTypingAttributes:typingAttributes];
NSRange rangeOfChange = NSMakeRange(0, [[myTextView string] length]);
[myTextView shouldChangeTextInRange:rangeOfChange 
replacementString:nil];
[[myTextView textStorage] setAttributes:typingAttributes 
range:rangeOfChange];
[myTextView didChangeText]; 
[typingAttributes release];
// end added code   

[attrs setObject:paraStyle forKey:NSParagraphStyleAttributeName];
[paraStyle release];
 
[[textView textStorage] addAttributes:attrs range:NSMakeRange(0, 
[[[textView textStorage] string] length])];
[attrs release];
}

Boyd



On Jun 5, 2010, at 9:16 AM, Ross Carter wrote:

> On Jun 5, 2010, at 1:09 AM, Boyd Collier wrote:
> 
>> In an application I'm working on, I read in plain text files containing data 
>> to be analyzed.  This uses a slightly-modified version of MyDocument.m that 
>> is produced as a result of starting a project with the template for 
>> NSDocument architecture.  The modification that I made was to add a method 
>> named updateView, which is called near the end of windowControllerDidLoadNib 
>> and loadDataRepresentation: ofType:  
>> 
>> My reason for adding this method is to make the spacing of tabs something 
>> that works well for the sort of data files being analyzed, which presume 
>> tabs are used to separate values being analyzed.  Here's the code:
> ...
>> [[textView textStorage] addAttributes:attrs range:NSMakeRange(0, [[[textView 
>> textStorage] string] length])];
> 
> 
> Couple of suggestions: 
> 
> 1. Call NSTextView -shouldChangeTextInRange:replacementString: before 
> modifying the textStorage, and call -didChangeText afterward.
> 
> 2. Look at NSTextView -setDefaultParagraphStyle:.
> ___
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] Preprocessing events sent to UITableView

2010-06-05 Thread glenn andreas
 
On Saturday, June 05, 2010, at 05:51PM, "WT"  wrote:
>I need to hijack the set of touch events sent to a UITableView instance prior 
>to allowing the table to process those events.
>
>I have a custom UIView, of which the table view is a subview, and I override 
>-hitTest:withEvent: there (in the custom view) to return self, thereby 
>preventing the table from receiving those touches.
>
>Since my custom view does not implement any of the four event-handling methods 
>(-touchesBegan:withEvent:, etc), the view controller managing my custom view 
>gets the touches, through the regular traversal of the responder chain.
>
>There, in the view controller event-handling methods, I determine whether or 
>not I need to consume the events. If not, I need to send them back to the 
>table view for it to do its normal event handling (for instance, scrolling).
>
>All of the above works fine, except...


Probably not as "fine" as you expect - UIViews are not designed to support 
UIEvents forwarded to them except under very controlled conditions.  From 
:

"The classes of the UIKit framework are not designed to receive touches that 
are not bound to them; in programmatic terms, this means that the view property 
of the UITouch object must hold a reference to the framework object in order 
for the touch to be handled. If you want to conditionally forward touches to 
other responders in your application, all of these responders should be 
instances of your own subclasses of UIView."

That document contains a number of suggestions on how to approach those sort of 
design issues...

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Cocoa: dragging files from Finder

2010-06-05 Thread Marcin Górski
Hello,

I'm new to Cocoa programming. I would like to be able to drag filenames from 
Finder to a custom view in my application. Both previous mails and Mr. Google 
redirect to Drag and Drop Programming Topics for Cocoa 
(http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/) . I've 
read this, but something still doesn't work.

Declaration of my custom view (a subclass of NSView) looks like:

@interface myView : NSView {
}
- (NSDragOperation)draggingEntered:(id )sender;
- (void)draggingExited:(id )sender;
- (BOOL)prepareForDragOperation:(id )sender;
- (BOOL)performDragOperation:(id )sender;
- (void)concludeDragOperation:(id )sender;
@end

then I have a dummy implementation that does nothing but writes to debugging 
console :

@implementation myView
- (id)init {
[super init];
[self registerForDraggedTypes: [NSArray arrayWithObject: 
NSFilenamesPboardType]];
return self;
}

- (NSDragOperation)draggingEntered:(id )sender  {
NSLog(@"draggingEntered:");
return NSDragOperationCopy;
} 

- (void)draggingExited:(id )sender {
NSLog(@"draggingExited:");
}

- (BOOL)prepareForDragOperation:(id )sender {
return YES;
}

- (BOOL)performDragOperation:(id )sender  {
NSLog(@"draggingOperation");
return YES;

}

- (void)concludeDragOperation:(id )sender {
NSLog(@"draggingFinished:");
}

In my AppController class (main class in app) I create new myView object and in 
Interface Builder this object is connected with a Custom View layout. But when 
I run my app and try anything from Finder the console remains silent. Can 
anyone tell me what I'm missing?

Thanks,
Marcin ___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: setting tab stops in a document

2010-06-05 Thread Paul Sanders
> When my application opens a text file, the insertion point is blinking 
> immediately after the last character on the last line.  If I then hit the tab 
> key, the insertion point moves over the correct distance.  However, if I hit 
> the return key when the file is first opened, the insertion point moves to 
> the start of the next line; if I then hit the tab key the insertion point 
> moves it over too few spaces (presumably the default distance rather than 
> what I tried to set in the above code).  

> What am I missing?

[NSTextView setTypingAttributes:] is what you are looking for.  Setting them is 
an all-or-nothing affair so, typically, you get them, change what you want to 
change in a mutable copy of the NSDictionary returned and and then set them.

Regards,

Paul Sanders.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Monster memory leak and I can't figure out why

2010-06-05 Thread Ken Ferry
   // Option 2
   NSImage *image
   = [[NSImage alloc] initWithContentsOfFile: inPath];

   /* do some stuff */

   [image release];

It seems very likely that the error is in the "do some stuff".

I built an app from your code and sat it in a while loop, and it didn't
leak.  It had the same behavior as you report for the second version of your
code.

-Ken
Cocoa Frameworks

On Wed, Jun 2, 2010 at 6:51 AM, Ken Tozier  wrote:

> Thanks all for the replies
>
> Re point #1: I was using Activity Monitor and both the "Real Memory" and
> "Virtual Memory" columns showed this 100+ MB leak every 5-10 seconds. After
> a minute or so of running, My app had gobbled up almost 2 gigs of memory.
>
> Re point #2: All the thumbnail conversion code is contained within this one
> method, so once it enters the loop, it doesn't exit till it's done.
>
> I tried using [[NSGarbageCollector defaultCollector] collectExhaustively],
> as Jonathan suggested, tried [image setCacheMode: NSImageCacheNever], but
> neither of those slowed the ferocious gobbling of memory.
>
> I finally resorted to using CGxxx functions and the problem disappeared. My
> App now hums along generating 12 to 15 thumbnails per second with a memory
> footprint in the 20 to 30 MB range. Here's what worked:
>
>
> - (NSString *) createJPEGThumbnail:(NSString *) inPath
>site:(NSString *) inSite
> {
>NSDictionary*siteRecord,
>*pubRecord;
>
>NSString*sourceName =
> [inPath lastPathComponent],
>*sourceRoot
> = [sourceName stringByDeletingPathExtension],
>*destName
> = [[sourceRoot stringByAddingPercentEscapesUsingEncoding:
> NSUTF8StringEncoding] stringByAppendingPathExtension: @"jpg"],
>*pubCode
>= [self pubCodeFromPath: inPath],
>*thumbPath;
>
>NSFileManager   *manager=
> [NSFileManager defaultManager];
>
>siteRecord  = [thumbDirectories
> objectForKey: inSite];
>
>pubRecord   = [[siteRecord objectForKey:
> @"publications"] objectForKey: pubCode];
>
>if (pubRecord == nil)
>pubRecord   = [[siteRecord objectForKey:
> @"publications"] objectForKey: @"~MISCELLANEOUS"];
>
>thumbPath   = [[pubRecord objectForKey:
> @"thumb_path"] stringByAppendingPathComponent: destName];
>
>if (![manager fileExistsAtPath: thumbPath])
>{
>NSURL   *sourceURL
>= [NSURL fileURLWithPath: inPath],
>
>  *destURL= [NSURL fileURLWithPath: thumbPath];
>
>NSString*imageType
>= UtilPreferredUTIForFile(inPath);
>NSNumber*maxPixels
>= [NSNumber numberWithInt: maxDimension];
>NSDictionary*sourceOptions  =
> [NSDictionary dictionaryWithObjectsAndKeys:
>
>imageType,
> kCGImageSourceTypeIdentifierHint,
>
>kCFBooleanFalse,
> kCGImageSourceShouldCache,
>
>kCFBooleanTrue,
> kCGImageSourceCreateThumbnailFromImageAlways,
>
>maxPixels,
> kCGImageSourceThumbnailMaxPixelSize,
>
>nil];
>
>
>CGImageSourceRefimageSourceCG   =
> CGImageSourceCreateWithURL((CFURLRef) sourceURL, (CFDictionaryRef)
> sourceOptions );
>if (imageSourceCG != NULL)
>{
>NSDictionary*imageProps
> = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(imageSourceCG, 0,
> NULL);
>int w
> = [[imageProps objectForKey: @"PixelWidth"]
> intValue],
>h
> = [[imageProps objectForKey: @"PixelHeight"]
> intValue];
>
>NSRect  thumbRect
> = [self thumbRectWithSize: NSMakeSize(w, h)];
>
>NSDictionary*destOptions
>= [NSDictionary dictionaryWithObjectsAndKeys:
>
>[NSNumber numberWithInt:
> thumbRect.size.width], kCGImageProper

Inserting an NSSearchField inside an NSMenuItem

2010-06-05 Thread augusto callejas
hi-

i'm adding an NSSearchField to an NSMenu by creating an NSMenuItem
and calling setView with the search field as the argument.  i'm able to display
the search field properly, but it doesn't gain focus (no blinking cursor in the
search field) either when the NSMenu is displayed or when i click on the search
field itself.  i found a previous discussion and none of its approaches have 
worked:

http://lists.apple.com/archives/cocoa-dev/2008/Jan/msg00138.html

my code:

NSMenuItem* firstItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] 
initWithTitle:@"Test" action:nil keyEquivalent:@""];
NSSearchField *cField = [[[NSSearchField alloc] 
initWithFrame:NSMakeRect(0.0, 0.0, 250.0, 22.0)] autorelease];
[menu addItem:firstItem];
[firstItem setView:cField];

any ideas?

thanks,
augusto.___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa: dragging files from Finder

2010-06-05 Thread Markus Spoettl
On Jun 3, 2010, at 1:27 PM, Marcin Górski wrote:
> In my AppController class (main class in app) I create new myView object and 
> in Interface Builder this object is connected with a Custom View layout. But 
> when I run my app and try anything from Finder the console remains silent. 
> Can anyone tell me what I'm missing?


If that is really the code you're using it could be your view is never actually 
dragging enabled, I believe your description points to that.

You can create a custom view in your nib by settings the class name in the 
"View Identity" tab to your class' name (in your case "myView"). Note however, 
that when a view is created in such a way, the designated initializer is not 
called because it's created in a different way. 

Therefore the view that is created didn't call -registerForDraggedTypes:, so it 
never enabled dragging for files. 

To fix the issue you can implement -awakeFromNib and call 
-registerForDraggedTypes: there.

Also note that the real designated initializer for NSViews is 
-initWithFrame:(NSRect)frameRect, not "init" as in your code (but that doesn't 
change the problem at hand).

Regards
Markus
--
__
Markus Spoettl

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSData Question... could be a bit odd

2010-06-05 Thread Jens Alfke

On Jun 5, 2010, at 2:00 PM, Development wrote:

> What I need to do is have a backwards copy of the data in memory that I can 
> quickly dump. The thing is I'm not entirely sure how I would go about getting 
> the data in to a new object backwards. Any ideas?

Create a new NSMutableData of the same length.
Copy the data from src.bytes to dst.mutableBytes, a byte at a time in reverse 
order. It’s a simple C for() loop.

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa: dragging files from Finder

2010-06-05 Thread Jens Alfke

On Jun 3, 2010, at 10:27 AM, Marcin Górski wrote:

> - (id)init {
>   [super init];
>   [self registerForDraggedTypes: [NSArray arrayWithObject: 
> NSFilenamesPboardType]];
>   return self;
> }

That method won’t be called. Objects loaded from nibs don’t go through the same 
initialization process as objects created from scratch. The right place to put 
this kind of setup code for a nib-loaded object is in an -awakeFromNib method. 
Try that and it should fix it.

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: PDFSelection from a range

2010-06-05 Thread Matthew Weinstein
A solution to my own problem. This is from a category I created for 
PDFDocument. Seems to work. The + and - 1's are strictly trial and error. Seems 
to work, even with some pretty complex PDFS (created by comicLife, for 
instance). Probably not the pithiest way to do this (ans is completely 
superfluous) but for the record:

-(PDFSelection *) selectFrom: (int) b to: (int) e
{
int bspot, espot;
int i, n;
int flag, totlen, plen;
PDFPage *bpage, *epage, *tpage;
PDFSelection *ans;
totlen=flag = 0;
if(!(b < e)) return nil;
n = [self pageCount];
for(i = 0; i< n; i++)
{
tpage = [self pageAtIndex: i];
plen = [[tpage string] length];
if(b < totlen + plen)
{
flag++;
bpage = tpage;
bspot = b - totlen;
}
if(b < totlen + plen)
{
flag++;
bpage = tpage;
bspot = b - totlen;
}
if(e <= totlen + plen)
{
flag++;
epage = tpage;
espot = e - totlen - 1;
}
if(flag >= 2) break;
totlen += (plen + 1);

}
if(flag < 2) return nil;
ans = [self selectionFromPage: bpage atCharacterIndex: bspot toPage: 
epage atCharacterIndex: espot];
return ans;
}



On Jun 5, 2010, at 7:16 PM, cocoa-dev-requ...@lists.apple.com wrote:

> Dear programmers,
> I think I must be missing some simple method in the api to do this, but, 
> given a range of a PDFDocument string, how do I convert that to a selection? 
> I found the PDFPage selection from range, but how do I find what pages a 
> selection for the document string covers?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: detecting touch and hold vs touch in UIButton

2010-06-05 Thread Roland King
or if you are coding for 3.2 or later, use a UILongPressGestureRecognizer and 
let it do all the work. 

On 06-Jun-2010, at 12:36 AM, Scott Andrew wrote:

> I believe the way to do this is to setup a timer on touchDown to fire once 
> after X number of seconds. Your touchUp and touchCancelled should kill the 
> timer if the timer is exists and is not invalidated. If you hit the timer you 
> are being held. When the timer is hit you restart the timer again for the 
> next check. 
> 
> Scott
> 
> 
> On Jun 4, 2010, at 7:16 PM, Alejandro Marcos Aragón wrote:
> 
>> Hi all,
>> 
>> I've been trying to detect touch and hold vs touch on a subclass of 
>> UIButton. I basically accomplished that by doing the following:
>> 
>> I first add the following when the button is created:
>> 
>> 
>>  [button addTarget:self action:@selector(sourceSelected:)
>>  forControlEvents:UIControlEventTouchUpInside];
>>  [button addTarget:self action:@selector(sourceTouchDown:) 
>>  forControlEvents:UIControlEventTouchDown];
>> 
>> Then in the functions:
>> 
>> - (void) sourceSelected:(UIButton*) sender {
>> 
>>  
>>  // cancel request for extended meny
>>  [NSObject cancelPreviousPerformRequestsWithTarget:self 
>> selector:@selector(sourceSelectedExtended:) object:sender];
>>  ...
>> }
>> 
>> - (void) sourceTouchDown:(UIButton*) sender {
>> 
>>  // give time before performing action
>>  [self performSelector:@selector(sourceSelectedExtended:) 
>> withObject:sender afterDelay:0.5];  
>> }
>> 
>> - (void) sourceSelectedExtended:(UIButton*) sender {
>> 
>>  // remove action from button
>>  [sender removeTarget:self action:@selector(sourceSelected:) 
>> forControlEvents:UIControlEventTouchUpInside];
>>  ...
>>  ...
>>  // give time before performing action
>>  [self performSelector:@selector(addSourceAction:) withObject:sender 
>> afterDelay:1.];  
>> 
>> }
>> 
>> - (void) addSourceAction:(UIButton*)sender {
>> 
>>  // remove action from button
>>  [sender addTarget:self action:@selector(sourceSelected:) 
>> forControlEvents:UIControlEventTouchUpInside];
>>  
>> }
>> 
>> 
>> 
>> Now, this works fine, but then I thought there must be an easier (and 
>> definitely more elegant) way to accomplish the same thing.
>> 
>> Can someone through me a line here?
>> 
>> Thank you all,
>> 
>> aa
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/scottandrew%40roadrunner.com
>> 
>> This email sent to scottand...@roadrunner.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
> 
> This email sent to r...@rols.org

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cross XIB references?

2010-06-05 Thread Matt Neuburg
On Sat, 05 Jun 2010 22:14:22 +0100, Jean-Fran?ois Brouillet 
said:
>So ... is there a way to refer to NIB1.objA from NIB2.objB ?

This is probably the most FAQ in the entire Cocoa universe, so check the
archives. But basically it's up to YOU to organize things so that there's a
chain of references that connects the instances you need connected. Both
objects can see certain objects in common (for example, they can both see
the shared application object, and therefore they can both see its
delegate), so there's the basis of one solution right there. (Or you could
just use an NSNotification.) m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: detecting touch and hold vs touch in UIButton

2010-06-05 Thread Matt Neuburg
On Fri, 4 Jun 2010 21:16:50 -0500, Alejandro Marcos Arag?n
 said:
>I've been trying to detect touch and hold vs touch on a subclass of UIButton.

I think you want to imitate Listing 3-3 of Event Handling in the iPhone
Application Programming Guide, handling the touches yourself. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com