Search Results

Search found 6486 results on 260 pages for 'cocoa touch'.

Page 13/260 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Cocoa UI Elements Not Updating

    - by spamguy
    I have a few Cocoa UI elements with outlet connexions to an object instantiated within an NSView object, which is in turn put there by an NSViewController. These elements, a definite progress bar and a text label, are not updating: the progress bar is dead and empty despite having its value change constantly, the text label does not unhide through [textLabel setHidden:NO], the text label does not change its string. What I know: There's no difference between binding values and setting them in code. Nothing changes either way. I've checked outlet connections. They're all there. I've tried [X displayIfNeeded], where X has been the UI objects themselves, the containing NSView, and the main window. No difference. [progressBar setUsesThreadedAnimation:YES] makes no difference. Interestingly, if I look at progressBar mid-program, _threadedAnimation is still NO. The object holding all these outlets and performing an import operation is in an NSOperationQueue owned by the NSViewController object. Thanks! EDIT: As suggested, I called [self performSelectorOnMainThread:@selector(updateProgress:) withObject:[NSNumber numberWithInt:myObject] waitUntilDone:NO]. (I've also tried waitUntilDone:YES.) It's still not updating. The debugger clearly shows updateProgress: taking place in the main thread, so I don't know what's missing.

    Read the article

  • Cocoa/AppleScript move file

    - by bogdan
    I have a list of file paths and a destination path. I need something (AppleScript, Cocoa) that will move the files from one location to an other. I first tried using the following AppleScript, just to see what happens: set the_folder to (choose folder) tell application "Finder" move selection to the_folder end tell The problem is that it just blindly tries to move a file, nothing like the way Finder actually moves files (i.e. if a file with that name already exists, the AppleScript just throws an error, while Finder would ask you if you want to replace the file). The solution I came up with involved NSFileManager. I won't post the code because it's quite long, but basically I just check if the file already exists before trying to move, and if it exists a NSAlert with Replace/Cancel buttons appear. I have 2 remaining problems: Authorization - if you try to do something to files where you don't have access, the Finder would ask you to authorize. My code just fails... Moving to external drives - when you try to move a file to a different drive, NSFileManager copies the file and then deletes the original. The problem is that NSFileManager doesn't provide anything which I could use to display a progress indicator of what's happening during the copy. Is there anything I could use that is able to move files without these problems? The way I see it, I'm pretty much stuck with checking if the files are writable by the current user and authorize NSFileManager if not (from my understanding of the Authorization Services, this will be quite hard to implement). Oh and, I would also need to check if the destination is on the same drive and if not, implement something with FSCopyObjectAsync so that it shows a progress indicator... Thanks!

    Read the article

  • My cocoa app won't capture key events

    - by Oscar
    Hi, i usually develop for iPhone. But now trying to make a pong game in Cocoa desktop application. Working out pretty well, but i can't find a way to capture key events. Here's my code: #import "PongAppDelegate.h" #define GameStateRunning 1 #define GameStatePause 2 #define BallSpeedX 10 #define BallSpeedY 15 @implementation PongAppDelegate @synthesize window, leftPaddle, rightPaddle, ball; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { gameState = GameStateRunning; ballVelocity = CGPointMake(BallSpeedX, BallSpeedY); [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES]; } - (void)gameLoop { if(gameState == GameStateRunning) { [ball setFrameOrigin:CGPointMake(ball.frame.origin.x + ballVelocity.x, ball.frame.origin.y + ballVelocity.y)]; if(ball.frame.origin.x + 15 > window.frame.size.width || ball.frame.origin.x < 0) { ballVelocity.x =- ballVelocity.x; } if(ball.frame.origin.y + 35 > window.frame.size.height || ball.frame.origin.y < 0) { ballVelocity.y =- ballVelocity.y; } } } - (void)keyDown:(NSEvent *)theEvent { NSLog(@"habba"); // Arrow keys are associated with the numeric keypad if ([theEvent modifierFlags] & NSNumericPadKeyMask) { [window interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; } else { [window keyDown:theEvent]; } } - (void)dealloc { [ball release]; [rightPaddle release]; [leftPaddle release]; [super dealloc]; } @end

    Read the article

  • Cocoa Touch: Creating and Adding Custom View

    - by Jason
    I create a custom view in cocoa touch that is superclassed by UIView and in my main controller I initialize it and then add it as a subview to the main view, but when I add it to the main view it calls my initializer method again and causes an infinite loop. Am I going about creating my custom view wrong? Here is the mainView (void)loadView { UIImage *tempImage = [UIImage imageNamed: @"image1.jpg"]; CustomImageContainer *testImage = [[CustomImageContainer alloc] initWithImage: tempImage andLabel: @"test image" onTop: true atX: 10 atY: 10]; [self.view addSubview: testImage]; } and the CustomImageContainer -(CustomImageContainer *) initWithImage: (UIImage *)imageToAdd andLabel: (NSString *)text onTop: (BOOL) top atX: (int) x_cord atY: (int) y_cord{ UIImageView *imageview_to_add = [[UIImageView alloc] initWithImage: imageToAdd]; imageview_to_add.frame = CGRectMake(0, 0, imageToAdd.size.width, imageToAdd.size.height); UILabel *label_to_add = [[UILabel alloc] init]; label_to_add.text = text; label_to_add.alpha = 50; label_to_add.backgroundColor = [UIColor blackColor]; label_to_add.textColor = [UIColor whiteColor]; [self addSubview: imageview_to_add]; self.frame = CGRectMake(x_cord, y_cord, imageToAdd.size.width, imageToAdd.size.height); if (top) { label_to_add.frame = CGRectMake(0, 0, imageview_to_add.frame.size.width, imageview_to_add.frame.size.height); //[self addSubview: label_to_add]; } else { label_to_add.frame = CGRectMake(0,.2 * imageview_to_add.frame.size.height, imageview_to_add.frame.size.width, imageview_to_add.frame.size.height); } [self addSubview: label_to_add]; [super init]; return self; }

    Read the article

  • Clean bindings with structs

    - by andyvn22
    I have a model class for which it makes quite a lot of sense to have NSSize and NSPoint instance variables. This is lovely. I'm trying to create an editing interface for this object. I'd like to bind to size.width and whatnot. This, of course, doesn't work. What's the cleanest, most Cocoa-y solution to this problem? Of course I could write separate accessors for the individual members of every struct I use, but it seems like there should be a better solution.

    Read the article

  • Creating a cocoa Application without nib files/fully pragmatic

    - by Moddy
    Yes, I know this goes against the whole MVC principle! However, I'm just trying to whip up a pretty trivial application - and I've pretty much implemented it pragmatically. However, I have a problem... I create an Empty Project, copy all the frameworks over and set the build settings - and I get errors about the executable.. or lack of executable. The build settings all appear fine, but it tells me there is no executable - it will build + run fine.. however it doesn't run. There is no error either - it just appears to run very fast and cleanly! Unless I try and run gdb which politely tells me I need to give it a file first.. Running… No executable file specified. Use the "file" or "exec-file" command. So I created a Cocoa Application, removed all the stuff I didn't need (i.e the MainMenu.xib file..) and now I can compile my code perfectly.. however it dies with complaining that its "Unable to load nib file: MainMenu, exiting" I have gone through the Project Symbols and see that the code actually relies upon the nib file heavily, even if you don't touch it code-wise. (MVC again I guess..) So my question is - is there a simple way to compile just what you code, no added nib files, just the code you write and the frameworks you add? I assume it would be a blank project but my experience tells me otherwise?!

    Read the article

  • Conceptual question about NSAutoreleasePools

    - by ryyst
    In my Cocoa program, wouldn't a really simple way of dealing with autoreleased objects be to just create a timer object inside the app delegate that calls the following method e.g. every 10 seconds: if (pool) { // Release & drain the current pool to free the memory. [pool release]; } // Create a new pool. pool = [[NSAutoreleasePool alloc] init]; The only problems I can imagine are: 1) If the above code runs in a separate thread, an object might get autoreleased between the release call to the old pool and the creation of the new pool - that seems highly unlikely though. 2) It's obviously not that efficient, because the pool might get released if there's nothing in it. Likewise, in the 10 second gap, many many objects might be autoreleased, causing the pool to grow a lot. Still, the above solution seems pretty suitable to small and simple projects. Why doesn't anybody use it? What's the best practice of using NSAutoreleasePools?

    Read the article

  • Cocoa framework development: sharing between projects

    - by e.James
    I am currently developing a handful of similar Cocoa desktop apps. In an effort to share code between them, I have identified a set of core classes and functions that can be common across all of these applications. I would like to bundle this common code into a framework which all of my current applications (and any future ones) can link against. Now, here's the hard part: I'm going to be developing this framework as I go, so I need each of my desktop apps to have a reference to it, but I want to be able to edit the framework source code from within each of the app projects and have the framework automatically rebuilt as required. For example, let's say I have the Xcode project for DesktopAppNumberOne open, and I decide that one of my framework classes needs to be changed. I would like to: Open and edit the source file for that framework class without having to open the framework project in Xcode. Hit "build" on DesktopAppNumberOne, and see the framework rebuilt first (because one of its sources has changed), then see parts of DesktopAppNumberOne rebuilt (because one of the frameworks it links against has changed). I can see how to do this with only one app and one framework, but I'm having trouble figuring out how to do it with multiple apps that share a single framework. Has anyone had success with this approach? Am I perhaps going about this the wrong way? Any help would be appreciated.

    Read the article

  • Looking for marg_setValue fix in iPhoneOS

    - by John Smith
    I am trying to compile a library originally written for Cocoa. Things are good until it looks for the function marg_setValue(). It says there is a syntax error before char in marg_setValue(argumentList,argumentOffset,char,(char)lua_toboolean(state,luaArgument)); (it's talking about the third argument, not (char) ) I am trying to port LuaObjectiveCBridge to the iPhone. It has two choices, either using Runtime or Foundation. I have discovered there are some problems with foundation so I am trying runtime. But the compiler is not co-operating.

    Read the article

  • Cocoa memory management - object going nil on me

    - by SirRatty
    Hi all, Mac OS X 10.6, Cocoa project, with retain/release gc I've got a function which: iterates over a specific directory, scans it for subfolders (included nested ones), builds an NSMutableArray of strings (one string per found subfolder path), and returns that array. e.g. (error handling removed for brevity). NSMutableArray * ListAllSubFoldersForFolderPath(NSString *folderPath) { NSMutableArray *a = [NSMutableArray arrayWithCapacity:100]; NSString *itemName = nil; NSFileManager *fm = [NSFileManager defaultManager]; NSDirectoryEnumerator *e = [fm enumeratorAtPath:folderPath]; while (itemName = [e nextObject]) { NSString *fullPath = [folderPath stringByAppendingPathComponent:itemName]; BOOL isDirectory; if ([fm fileExistsAtPath:fullPath isDirectory:&isDirectory]) { if (isDirectory is_eq YES) { [a addObject: fullPath]; } } } return a; } The calling function takes the array just once per session, keeps it around for later processing: static NSMutableArray *gFolderPaths = nil; ... gFolderPaths = ListAllSubFoldersForFolderPath(myPath); [gFolderPaths retain]; All appears good at this stage. [gFolderPaths count] returns the correct number of paths found, and [gFolderPaths description] prints out all the correct path names. The problem: When I go to use gFolderPaths later (say, the next run through my event loop) my assertion code (and gdb in Xcode) tells me that it is nil. I am not modifying gFolderPaths in any way after that initial grab, so I am presuming that my memory management is screwed and that gFolderPaths is being released by the runtime. My assumptions/presumptions I do not have to retain each string as I add it to the mutable array because that is done automatically, but I do have to retain the the array once it is handed over to me from the function, because I won't be using it immediately. Is this correct? Any help is appreciated.

    Read the article

  • Cocoa button won't display image

    - by A Mann
    Just started exploring Cocoa so pretty much a total noob. I've written a very simple game. Set it up in Interface Builder and got it working fine. It contains a number of buttons and I'm now trying to get the buttons to display images. To start with I'm trying to get an image displayed on just one of the buttons which is called tile0 . The image file (it's nothing but a green square at the moment, but I'm just trying to get that working before I attempt anything more exotic) is sitting in the same directory as the class file which controls the game. I have the following code sitting in my wakeFromNib method: NSString *myImageFileName = [[NSString alloc] init]; myImageFileName = @"greenImage.jpg"; NSImage *myImage = [[NSImage alloc] initByReferencingFile:myImageFileName]; [tile0 setImage: myImage]; Trouble is, the game runs fine, but the image isn't appearing on my button. Is there someone who could kindly tell me if I'm doing something obviously wrong? Many Thanks.

    Read the article

  • COCOA: Programatically creating new windows and accessing window objects

    - by Jeffrey Kern
    I'm having an issue with creating new windows in Cocoa. Hypothetically speaking, lets say I have "WindowA" and has a button called "myButton". When you click on "myButton", it runs this code in the following class file: -(void)openFile2:(id)sender { myNextWindow = [[TestWindowController alloc] initWithWindowNibName:@"MainMenu"]; NSString *testString = @"foo"; [myNextWindow showWindow:self]; [myNextWindow setButtonText:testString]; } The code in a nutshell makes a duplicate "WindowA" and shows it. As you can see, this code also runs a method called 'setButtonText', which is this: - (void)setButtonText:(NSString *)passedText { [myButton setTitle:passedText]; } The problem is that when I call this method locally, in the original window - the button text changes (e.g., [self setButtonText:testString]) it works. However, it does not work in the newly created window (e.g., [myNextWindow setButtonText:testString];) When I debug the newly created window, step by step, the 'myButton' value it gives is 0x0. Do I have to manually assign controllers/delegates to the new window? I think the 'myButton' in the code isn't associated to the 'myButton' in the newly created window. How would I fix this problem?

    Read the article

  • Screenshot Tour: Ubuntu Touch 14.04 on a Nexus 7

    - by Chris Hoffman
    Ubuntu 14.04 LTS will “form the basis of the first commercially available Ubuntu tablets,” according to Canonical. We installed Ubuntu Touch 14.04 on our own hardware to see what those tablets will be like. We don’t recommend installing this yourself, as it’s still not a polished, complete experience. We’re using “Ubuntu Touch” as shorthand here — apparently this project’s new name is “Ubuntu For Devices.” The Welcome Screen Ubuntu’s touch interface is all about edge swipes and hidden interface elements — it has a lot in common with Windows 8, actually. You’ll see the welcome screen when you boot up or unlock a Ubuntu tablet or phone. If you have new emails, text messages, or other information, it will appear on this screen along with the time and date. If you don’t, you’ll just see a message saying “No data sources available.” The Dash Swipe in from the right edge of the welcome screen to access the Dash, or home screen. This is actually very similar to the Dash on Ubuntu’s Unity desktop. This isn’t a surprise — Canonical wants the desktop and touch versions of Ubuntu to use the same code. In the future, the desktop and touch versions of Ubuntu will use the same version of Unity and Unity will adjust its interface depending on what type of device your’e using. Here you’ll find apps you have installed and apps available to install. Tap an installed app to launch it or tap an available app to view more details and install it. Tap the My apps or Available headings to view a complete list of apps you have installed or apps you can install. Tap the Search box at the top of the screen to start searching — this is how you’d search for new apps to install. As you’d expect, a touch keyboard appears when you tap in the Search field or any other text field. The launcher isn’t just for apps. Tap the Apps heading at the top of the screen and you’ll see hidden text appear — Music, Video, and Scopes. This hidden navigation is used throughout Ubuntu’s different apps and can be easy to miss at first. Swipe to the left or right to move between these screens. These screens are also similar to the different panels in Unity on the desktop. The Scopes section allows you to view different search scopes you have installed. These are used to search different sources when you start a search from the Dash. Search from the Music or Videos scopes to search for local media files on your device or media files online. For example, searching in the Music scope will show you music results from Grooveshark by default. Navigating Ubuntu Touch Swipe in from the left edge anywhere on the system to open the launcher, a bar with shortcuts to apps. This launcher is very similar to the launcher on the left of Ubuntu’s Unity desktop — that’s the whole idea, after all. Once you’ve opened an app, you can leave the app by swiping in from the left. The launcher will appear — keep moving your finger towards the right edge of teh screen. This will swipe the current app off the screen, taking you back to the Dash. Once back on the Dash, you’ll see your open apps represented as thumbnails under Recent. Tap a thumbnail here to go back to a running app. To remove an app from here, long-press it and tap the X button that appears. Swipe in from the right edge in any app to quickly switch between recent apps. Swipe in from the right edge and hold your finger down to reveal an application switcher that shows all your recent apps and lets you choose between them. Swipe down from the top of the screen to access the indicator panel. Here you can connect to Wi-Fi networks, view upcoming events, control GPS and Bluetooth hardware, adjust sound settings, see incoming messages, and more. This panel is for quick access to hardware settings and notifications, just like the indicators on Ubuntu’s Unity desktop. The Apps System settings not included in the pull-down panel are available in the System Settings app. To access it, tap My apps on the Dash and tap System Settings, search for the System Settings app, or open the launcher bar and tap the settings icon. The settings here a bit limited compared to other operating systems, but many of the important options are available here. You can add Evernote, Ubuntu One, Twitter, Facebook, and Google accounts from here. A free Ubuntu One account is mandatory for downloading and updating apps. A Google account can be used to sync contacts and calendar events. Some apps on Ubuntu are native apps, while many are web apps. For example, the Twitter, Gmail, Amazon, Facebook, and eBay apps included by default are all web apps that open each service’s mobile website as an app. Other applications, such as the Weather, Calendar, Dialer, Calculator, and Notes apps are native applications. Theoretically, both types of apps will be able to scale to different screen resolutions. Ubuntu Touch and Ubuntu desktop may one day share the same apps, which will adapt to different display sizes and input methods. Like Windows 8 apps, Ubuntu apps hide interface elements by default, providing you with a full-screen view of the content. Swipe up from the bottom of an app’s screen to view its interface elements. For example, swiping up from the bottom of the Web Browser app reveals Back, Forward, and Refresh buttons, along with an address bar and Activity button so you can view current and recent web pages. Swipe up even more from the bottom and you’ll see a button hovering in the middle of the app. Tap the button and you’ll see many more settings. This is an overflow area for application options and functions that can’t fit on the navigation bar. The Terminal app has a few surprising Easter eggs in this panel, including a “Hack into the NSA” option. Tap it and the following text will appear in the terminal: That’s not very nice, now tracing your location . . . . . . . . . . . .Trace failed You got away this time, but don’t try again. We’d expect to see such Easter eggs disappear before Ubuntu Touch actually ships on real devices. Ubuntu Touch has come a long way, but it’s still not something you want to use today. For example, it doesn’t even have a built-in email client — you’ll have to us your email service’s mobile website. Few apps are available, and many of the ones that are are just mobile websites. It’s not a polished operating system intended for normal users yet — it’s more of a preview for developers and device manufacturers. If you really want to try it yourself, you can install it on a Wi-Fi Nexus 7 (2013), Nexus 10, or Nexus 4 device. Follow Ubuntu’s installation instructions here.

    Read the article

  • get current selected button cell placed inside tableview using cocoa

    - by Swati
    hi i have a NSTableView i have two columns A and B B contains some data A contains custom button the button is added to column A using this: Below code is placed inside awakeFromNib method NSButtonCell *buttonCell = [[[NSButtonCell alloc] init] autorelease]; [buttonCell setBordered:NO]; [buttonCell setImagePosition:NSImageOnly]; [buttonCell setButtonType:NSMomentaryChangeButton]; [buttonCell setImage:[NSImage imageNamed:@"uncheck.png"]]; [buttonCell setSelectable:TRUE]; [buttonCell setTag:100]; [buttonCell setTarget:self]; [buttonCell setAction:@selector(selectButtonsForDeletion:)]; [[myTable tableColumnWithIdentifier:@"EditIdentifier"] setDataCell:buttonCell]; Some code in display cell of nstableview: -(void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex { if(tableView == myTable) { if([[tableColumn identifier] isEqualToString:@"DataIdentifier"]) { } else if([[tableColumn identifier] isEqualToString:@"EditIdentifier"]) { NSButtonCell *zCell = (NSButtonCell *)cell; [zCell setTag:rowIndex]; [zCell setTitle:@"abc"]; [zCell setTarget:self]; [zCell setAction:@selector(selectButtonsForDeletion:)]; } } } now i want that when i click on the button the image of button cell gets changed as well as i want to do some coding. When button gets clicked then by default the tableView's reference gets passed. How can i get the button cell reference i looked here for similar problem: Cocoa: how to nest a button inside a Table View cell? but i am unable to add button inside column of NSTableView. How i change the image: - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row; { if(tableView == myTable) { if([[tableColumn identifier] isEqualToString:@"EditIdentifier"]) { NSButtonCell *aCell = (NSButtonCell *)[[tableView tableColumnWithIdentifier:@"EditIdentifier"] dataCellForRow:row]; NSInteger index = [[aCell title]intValue]; if([self.selectedIndexesArray count]>0) { if(![self.selectedIndexesArray containsObject:[NSNumber numberWithInt:index]]) { [aCell setImage:[NSImage imageNamed:@"check.png"]]; [self.selectedIndexesArray addObject:[NSNumber numberWithInt:index]]; } else { [aCell setImage:[NSImage imageNamed:@"uncheck.png"]]; [self.selectedIndexesArray removeObjectAtIndex:[selectedIndexesArray indexOfObject:[NSNumber numberWithInt:index]]]; } } else { [aCell setImage:[NSImage imageNamed:@"check.png"]]; [self.selectedIndexesArray addObject:[NSNumber numberWithInt:index]]; } } } } I have debugged the code and found that proper tag and titles are passed but image applies on more than one button cell, this is too very irregular. cant understand how its working!!! Any suggestions what am i doing wrong??

    Read the article

  • Cocoa NSOutputStream send to a connection

    - by Chuck
    Hi, I am new to Cocoa, but managed to get a connection (to a FTP) up and running, and I've set up an eventhandler for the NSInputStream iStream to alert every response (which also works). What I manage to get is simply the hello message and a connection timeout 60 sec, closing control connection. After searching stackoverflow and finding a lot of NSOutputStream write problems (e.g. http://stackoverflow.com/questions/703729/how-to-use-nsoutputstreams-write-message) and a lot of confusion in my google hits, I figured I'd try to ask my own question: I've tried reading the developer.apple.com doc on OutputStream, but it seems almost impossible for me to send some data (in this case just a string) to the "connection" via the NSOutputStream oStream. - (IBAction) send_something: sender { const char *send_command_char = [@"USER foo" UTF8String]; send_command_buffer = [NSMutableData dataWithBytes:send_command_char length:strlen(send_command_char) + 1]; uint8_t *readBytes = (uint8_t *)[send_command_buffer mutableBytes]; NSInteger byteIndex = 0; readBytes += byteIndex; int data_len = [send_command_buffer length]; unsigned int len = ((data_len - byteIndex >= 1024) ? 1024 : (data_len-byteIndex)); uint8_t buf[len]; (void)memcpy(buf, readBytes, len); len = [oStream write:(const uint8_t *)buf maxLength:len]; byteIndex += len; } the above seems not to result in any useable events. typing it under NSStreamEventHasSpaceAvailable sometimes give a response if I spam the ftp by keep creating new connection instances and keep sending some command whenever oStream has free space. In other words, nothing "right" and so I'm still unclear how to properly send a command to the connection. Should I open - write - close every time i want to write to oStream (and thus to the ftp) and can I then expect a reply (hasBytesAvailable event on iStream)? For some reason I find it very difficult to find any clear tutorials on this matter. Seems like there are more than a few in the same position as me: unclear how to use oStream write? Any little bit that can help clear this up is greatly appreciated! If needed I can write the rest of the code. Chuck

    Read the article

  • Get the touch position inside the imageview in android

    - by Manikandan
    I have a imageview in my activity and I am able to get the position where the user touch the imageview, through onTouchListener. I placed another image where the user touch over that image. I need to store the touch position(x,y), and use it in another activity, to show the tags. I stored the touch position in the first activity. In the first activity, my imageview at the top of the screen. In the second activity its at the bottom of the screen. If I use the position stored from the first acitvity, it place the tag image at the top, not on the imageview, where I previously clicked in the first activity. Is there anyway to get the position inside the imageview. FirstActivity: cp.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub Log.v("touched x val of cap img >>", event.getX() + ""); Log.v("touched y val of cap img >>", event.getY() + ""); x = (int) event.getX(); y = (int) event.getY(); tag.setVisibility(View.VISIBLE); int[] viewCoords = new int[2]; cp.getLocationOnScreen(viewCoords); int imageX = x - viewCoords[0]; // viewCoods[0] is the X coordinate int imageY = y - viewCoords[1]; // viewCoods[1] is the y coordinate Log.v("Real x >>>",imageX+""); Log.v("Real y >>>",imageY+""); RelativeLayout rl = (RelativeLayout) findViewById(R.id.lay_lin); ImageView iv = new ImageView(Capture_Image.this); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.tag_icon_32); iv.setImageBitmap(bm); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = x; params.topMargin = y; rl.addView(iv, params); Intent intent= new Intent(Capture_Image.this,Tag_Image.class); Bundle b=new Bundle(); b.putInt("xval", imageX); b.putInt("yval", imageY); intent.putExtras(b); startActivity(intent); return false; } }); In TagImage.java I used the following: im = (ImageView) findViewById(R.id.img_cam22); b=getIntent().getExtras(); xx=b.getInt("xval"); yy=b.getInt("yval"); im.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int[] viewCoords = new int[2]; im.getLocationOnScreen(viewCoords); int imageX = xx + viewCoords[0]; // viewCoods[0] is the X coordinate int imageY = yy+ viewCoords[1]; // viewCoods[1] is the y coordinate Log.v("Real x >>>",imageX+""); Log.v("Real y >>>",imageY+""); RelativeLayout rl = (RelativeLayout) findViewById(R.id.lay_lin); ImageView iv = new ImageView(Tag_Image.this); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.tag_icon_32); iv.setImageBitmap(bm); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( 30, 40); params.leftMargin =imageX ; params.topMargin = imageY; rl.addView(iv, params); return true; } });

    Read the article

  • Slow Javascript touch events on Android

    - by oneself
    I'm trying to write a simple html based drawing application (standalone simplified code attached bellow). I've tested this on the following devices: iPad 1 and 2: Works great ASUS T101 running Windows: Works great Samsung Galaxy Tab: Extremely slow and patchy -- unusable. Lenovo IdeaPad K1: Extremely slow and patchy -- unusable. Asus Transformer Prime: Noticeable lag compare with the iPad -- close to usable. The Asus tablet is running ICS, the other android tablets are running 3.1 and 3.2. I tested using the stock Android browser. I also tried the Android Chrome Beta, but that was even worse. My questions is why are the Android tablets so slow? Am I doing something wrong or is it an inherit problem with Android OS or browser, or is there anything I can do about it in my code? multi.html: <html> <body> <style media="screen"> canvas { border: 1px solid #CCC; } </style> <canvas style="" id="draw" height="450" width="922"></canvas> <script class="jsbin" src="jquery.js"></script> <script src="multi.js"></script> </body> </html> multi.js: var CanvasDrawr = function(options) { // grab canvas element var canvas = document.getElementById(options.id), ctxt = canvas.getContext("2d"); canvas.style.width = '100%' canvas.width = canvas.offsetWidth; canvas.style.width = ''; // set props from options, but the defaults are for the cool kids ctxt.lineWidth = options.size || Math.ceil(Math.random() * 35); ctxt.lineCap = options.lineCap || "round"; ctxt.pX = undefined; ctxt.pY = undefined; var lines = [,,]; var offset = $(canvas).offset(); var eventCount = 0; var self = { // Bind click events init: function() { // Set pX and pY from first click canvas.addEventListener('touchstart', self.preDraw, false); canvas.addEventListener('touchmove', self.draw, false); }, preDraw: function(event) { $.each(event.touches, function(i, touch) { var id = touch.identifier; lines[id] = { x : this.pageX - offset.left, y : this.pageY - offset.top, color : 'black' }; }); event.preventDefault(); }, draw: function(event) { var e = event, hmm = {}; eventCount += 1; $.each(event.touches, function(i, touch) { var id = touch.identifier, moveX = this.pageX - offset.left - lines[id].x, moveY = this.pageY - offset.top - lines[id].y; var ret = self.move(id, moveX, moveY); lines[id].x = ret.x; lines[id].y = ret.y; }); event.preventDefault(); }, move: function(i, changeX, changeY) { ctxt.strokeStyle = lines[i].color; ctxt.beginPath(); ctxt.moveTo(lines[i].x, lines[i].y); ctxt.lineTo(lines[i].x + changeX, lines[i].y + changeY); ctxt.stroke(); ctxt.closePath(); return { x: lines[i].x + changeX, y: lines[i].y + changeY }; }, }; return self.init(); }; $(function(){ var drawr = new CanvasDrawr({ id: "draw", size: 5 }); });

    Read the article

  • UIButton title disappears on touch

    - by psychotik
    I want a touchable UILabel, but since that's not possible I decided to create a UIButton of type UIButtonTypeCustom. It looks how I want it to look, but when I touch it, the title disappears. I tried setting the title for state UIControlStateHighlighted but that didn't help. I know I'm doing something really silly here, but can't figure it out. I tried a few things (commented in the code below) which didn't seem to help. Here's how I'm configuring the button: UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(0, 0, width, height); button.clearsContextBeforeDrawing = YES; button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; button.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; button.enabled = YES; button.hidden = NO; button.highlighted = NO; button.opaque = YES; button.selected = NO; button.userInteractionEnabled = YES; button.showsTouchWhenHighlighted = NO; [button setTitle:@"Hello World" forState:UIControlStateNormal]; button.titleLabel.font = [UIFont boldSystemFontOfSize:16]; button.titleLabel.textColor = [UIColor blackColor]; // Things I tried that didn't help //[button setBackgroundColor:[UIColor clearColor]]; //button.titleLabel.text = @"Hello World"; //[button setTitle:@"Hello World" forState:UIControlStateHighlighted]; Any ideas?

    Read the article

  • How do I set the default selection for NSTreeController at startup?

    - by John Gallagher
    The Background I've built a source list (similar to iTunes et al.) in my Cocoa app. I've got an NSOutlineView, with Value column bound to arrangedObjects.name key path of an NSTreeController. The NSTreeController accesses JGSourceListNode entities in a Core Data store. I have three subclasses of JGSourceListNode - JGProjectNode, JGGroupNode and JGFolderNode. I have selectedIndexPaths on NSTreeController bound to an NSArray called selectedIndexPaths in my App Delegate. On startup, I search for group nodes and if they're not found in the core data store I create them: if ([allGroupNodes count] == 0) { JGGroupNode *rootTrainingNode = [JGGroupNode insertInManagedObjectContext:context]; [rootTrainingNode setNodeName:@"TRAIN"]; JGProjectNode *childUntrainedNode = [JGProjectNode insertInManagedObjectContext:context]; [childUntrainedNode setParent:rootTrainingNode]; [childUntrainedNode setNodeName:@"Untrained"]; JGGroupNode *rootBrowsingNode = [JGGroupNode insertInManagedObjectContext:context]; [rootBrowsingNode setNodeName:@"BROWSE"]; JGFolderNode *childFolder = [JGFolderNode insertInManagedObjectContext:context]; [childFolder setNodeName:@"Folder"]; [childFolder setParent:rootBrowsingNode]; [context save:nil]; } What I Want When I start the app, I want both top level groups to be expanded and "Untrained" to be highlighted as shown: The Problem I put the following code in the applicationDidFinishLaunching: method of the app delegate: [sourceListOutlineView expandItem:[sourceListOutlineView itemAtRow:0]]; [sourceListOutlineView expandItem:[sourceListOutlineView itemAtRow:2]]; NSIndexPath *rootIndexPath = [NSIndexPath indexPathWithIndex:0]; NSIndexPath *childIndexPath = [rootIndexPath indexPathByAddingIndex:0]; [self setSelectedIndexPaths:[NSArray arrayWithObject:childIndexPath]]; but the outline view seems to not have been prepared yet, so this code does nothing. Ideally, eventually I want to save the last selection the user had made and restore this on a restart. The Question I'm sure it's possible using some crazy KVO to observe when the NSTreeController or NSOutlineView gets populated then expand the items and change the selection, but that feels clumsy and too much like a work around. How would I do this elegantly?

    Read the article

  • What do you need to implement to provide a Content Set for an NSArrayController?

    - by whuuh
    Heys, I am writing something in Xcode. I use Core Data for persistency and link the view and the model together with Cocoa Bindings; pretty much your ordinary Core Data application. I have an array controller (NSArrayController) in my Xib. This has its managedObjectContext bound to the AppDelegate, as is convention, and tracks an entity. So far so good. Now, the "Content Set" biding of this NSArrayController limits its content set (as you'd expect), by a keyPath from the selection in another NSArrayController (otherAc.selection.detailsOfMaster). This is the usual way to implement a Master-Detail relationship. I want to variably change the key path at runtime, using other controls. This way, I sould return a content set that includes several other content sets, which is all advanced and beyond Interface Builder. To achieve this, I think I should bind the Content Set to my AppDelegate instead. I have tried to do this, but don't know what methods to implement. If I just create the KVC methods (objectSet, setObjectSet), then I can provide a Content Set for the Array Controller in the contentSet method. However, I don't think I'm binding this properly, because it doesn't "refresh". I'm new to binding; what do I need to implement to properly update the Content Set when other things, like the selection in the master NSArrayController, changes?

    Read the article

  • Why are the default UI controls in my iPhone app blurred?

    - by Tom H
    Why would the default iPhone interface elements, specifically the UISwitch (unmodified) and a UISegmentedControl appear slightly blurred? I have not changed them or called any private APIs. This blurring occurs when I run it both in the simulator and when I load it on my iPod Touch, so I don't think it's a one off drawing glitch. These elements were created via some code (initWithFrame:) not in interface builder. Here is a screenshot of the blurring in the simulator: http://drp.ly/14rS6a It looks similar on the actual device. Thanks for your help

    Read the article

  • NotApplicable marker with display pattern

    - by Jeff Barger
    Ok, so I'm pretty new to Cocoa, especially Bindings, but here's what I'm trying to do. I've got a Core Data model consisting of two entities: Category and Item. Category has a to-many relationship to Item called children, and Item has a relationship to Category called parent. Item has two attributes that Category does not have: quantity and desiredQuantity. What I'd like to do is display the tree in an NSOutlineView with two columns. One column is bound to the name of either the Category or the Item. I want to the second column to display something along the lines of 2 of 5 for the Item rows and nothing at all for the Category rows. When I use a display pattern, the Category rows end up showing of I noticed that if I don't use a display pattern for the second column, and instead just bind its Value to either the quantity or the desiredQuantity, the Category rows show nothing; its only if I try to use the display pattern. How can I make it display nothing for the Category rows and still use the display pattern? Or can I? Edit: I guess I didn't explain what the NotApplicable marker has to do with anything - Category does have properties for quantity and desiredQuantity, but they just return NSNotApplicableMarker.

    Read the article

  • Cocoa nextEventMatchingMask not receiving NSMouseMoved event

    - by Jonny
    Hello, I created a local event loop and showed up a borderless window (derived from NSPanel), I found in the event loop there's no NSMouseMoved event received, although I can receive Mouse button down/up events. What should I do to get the NSMouseMoved events? I found making the float window as key window can receive the NSMouseMoved events, but I don't want to change key window. And it appears this is possible, because I found after clicking the test App Icon in System Dock Bar, I can receive the mousemoved events, and the key window/mainwindow are unchanged. Here's the my test code: (Create a Cocoa App project names FloatWindowTest, and put a button to link it with the onClick: IBAction). Thanks in advance! -Jonny #import "FloatWindowTestAppDelegate.h" @interface FloatWindow : NSPanel @end @interface FloatWindowContentView : NSView @end @implementation FloatWindowTestAppDelegate @synthesize window; - (void)delayedAction:(id)sender { // What does this function do? // 1. create a float window // 2. create a local event loop // 3. print out the events got from nextEventMatchingMask. // 4. send it to float window. // What is the problem? // In local event loop, althrough the event mask has set NSMouseMovedMask // there's no mouse moved messages received. // FloatWindow* floatWindow = [[FloatWindow alloc] init]; NSEvent* event = [NSApp currentEvent]; NSPoint screenOrigin = [[self window] convertBaseToScreen:[event locationInWindow]]; [floatWindow setFrameTopLeftPoint:screenOrigin]; [floatWindow orderFront:nil]; //Making the float window as Key window will work, however //change active window is not anticipated. //[floatWindow makeKeyAndOrderFront:nil]; BOOL done = NO; while (!done) { NSAutoreleasePool* pool = [NSAutoreleasePool new]; NSUInteger eventMask = NSLeftMouseDownMask| NSLeftMouseUpMask| NSMouseMovedMask| NSMouseEnteredMask| NSMouseExitedMask| NSLeftMouseDraggedMask; NSEvent* event = [NSApp nextEventMatchingMask:eventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES]; //why I cannot get NSMouseMoved event?? NSLog(@"new event %@", [event description]); [floatWindow sendEvent:event]; [pool drain]; } [floatWindow release]; return; } -(IBAction)onClick:(id)sender { //Tried to postpone the local event loop //after return from button's mouse tracking loop. //but not fixes this problem. [[NSRunLoop currentRunLoop] performSelector:@selector(delayedAction:) target:self argument:nil order:0 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]]; } @end @implementation FloatWindow - (id)init { NSRect contentRect = NSMakeRect(200,300,200,300); self = [super initWithContentRect:contentRect styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:YES]; if (self) { [self setLevel:NSFloatingWindowLevel]; NSRect frameRect = [self frameRectForContentRect:contentRect]; NSView* view = [[[FloatWindowContentView alloc] initWithFrame:frameRect] autorelease]; [self setContentView:view]; [self setAcceptsMouseMovedEvents:YES]; [self setIgnoresMouseEvents:NO]; } return self; } - (BOOL)becomesKeyOnlyIfNeeded { return YES; } - (void)becomeMainWindow { NSLog(@"becomeMainWindow"); [super becomeMainWindow]; } - (void)becomeKeyWindow { NSLog(@"becomeKeyWindow"); [super becomeKeyWindow]; } @end @implementation FloatWindowContentView - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { return YES; } - (BOOL)acceptsFirstResponder { return YES; } - (id)initWithFrame:(NSRect)frameRect { self = [super initWithFrame:frameRect]; if (self) { NSTrackingArea* area; area = [[NSTrackingArea alloc] initWithRect:frameRect options:NSTrackingActiveAlways| NSTrackingMouseMoved| NSTrackingMouseEnteredAndExited owner:self userInfo:nil]; [self addTrackingArea:area]; [area release]; } return self; } - (void)drawRect:(NSRect)rect { [[NSColor redColor] set]; NSRectFill([self bounds]); } - (BOOL)becomeFirstResponder { NSLog(@"becomeFirstResponder"); return [super becomeFirstResponder]; } @end

    Read the article

  • Cocoa Basic HTTP Authentication : Advice Needed..

    - by Kristiaan
    Hello all, im looking to read the contents of a webpage that is secured with a user name and password. this is a mac OS X application NOT an iphone app so most of the things i have read on here or been suggested to read do not seem to work. Also i am a total beginner with Xcode and Obj C i was told to have a look at a website that provided sample code to http auth however so far i have had little luck in getting this working. below is the main code for the button press in my application, there is also another unit called Base64 below that has some code in i had to change to even get it compiling (no idea if what i changed is correct mind you). NSURL *url = [NSURL URLWithString:@"my URL"]; NSString *userName = @"UN"; NSString *password = @"PW"; NSError *myError = nil; // create a plaintext string in the format username:password NSMutableString *loginString = (NSMutableString*)[@"" stringByAppendingFormat:@"%@:%@", userName, password]; // employ the Base64 encoding above to encode the authentication tokens char *encodedLoginData = [base64 encode:[loginString dataUsingEncoding:NSUTF8StringEncoding]]; // create the contents of the header NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@", [NSString stringWithCString:encodedLoginData length:strlen(encodedLoginData)]]; //NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@", loginString];//[NSString stringWithString:loginString length:strlen(loginString)]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url cachePolicy: NSURLRequestReloadIgnoringCacheData timeoutInterval: 3]; // add the header to the request. Here's the $$$!!! [request addValue:authHeader forHTTPHeaderField:@"Authorization"]; // perform the reqeust NSURLResponse *response; NSData *data = [NSURLConnection sendSynchronousRequest: request returningResponse: &response error: &myError]; //*error = myError; // POW, here's the content of the webserver's response. NSString *result = [NSString stringWithCString:[data bytes] length:[data length]]; [myTextView setString:result]; code from the BASE64 file #import "base64.h" static char *alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; @implementation Base64 +(char *)encode:(NSData *)plainText { // create an adequately sized buffer for the output. every 3 bytes // become four basically with padding to the next largest integer // divisible by four. char * encodedText = malloc((((([plainText length] % 3) + [plainText length]) / 3) * 4) + 1); char* inputBuffer = malloc([plainText length]); inputBuffer = (char *)[plainText bytes]; int i; int j = 0; // encode, this expands every 3 bytes to 4 for(i = 0; i < [plainText length]; i += 3) { encodedText[j++] = alphabet[(inputBuffer[i] & 0xFC) >> 2]; encodedText[j++] = alphabet[((inputBuffer[i] & 0x03) << 4) | ((inputBuffer[i + 1] & 0xF0) >> 4)]; if(i + 1 >= [plainText length]) // padding encodedText[j++] = '='; else encodedText[j++] = alphabet[((inputBuffer[i + 1] & 0x0F) << 2) | ((inputBuffer[i + 2] & 0xC0) >> 6)]; if(i + 2 >= [plainText length]) // padding encodedText[j++] = '='; else encodedText[j++] = alphabet[inputBuffer[i + 2] & 0x3F]; } // terminate the string encodedText[j] = 0; return encodedText;//outputBuffer; } @end when executing the code it stops on the following line with a EXC_BAD_ACCESS ?!?!? NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@", [NSString stringWithCString:encodedLoginData length:strlen(encodedLoginData)]]; any help would be appreciated as i am a little clueless on this problem, not being very literate with Cocoa, objective c, xcode is only adding fuel to this fire for me.

    Read the article

  • Does the Wacom Bamboo Pen & Touch work out of the box?

    - by Emilien
    Is there any tweaking involved in Ubuntu 10.10 to make the Wacom Bamboo Pen & Touch work? And is this hardware getting some love from the new multitouch framework? If there's no multitouch support for it, then I'd fall back on the simpler (and cheaper) Wacom Bamboo Pen (to draw, no multitouch)... ENAC's general list of Linux multitouch devices states the following regarding Wacom: "The 'wacom' kernel driver handles these, and is undergoing work to make it compliant with the kernel multitouch protocol." But is this also compatible with Ubuntu's multitouch protocol (which I understand is a different effort than the kernel's)

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >