Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

How do I handle events in Cocoa?

Name: Anonymous 2011-05-21 4:57

Yeah....

http://pastebin.com/EkSf2Cf5

Basically makes a window with a text field in it and uses a while loop to keep it alive until I need it to stop, then frees all the pointers. Unfortunately, every time I hover over the window with my mouse, it has the pinwheel of death and the window can't accept events, such as for example, clicking the x button to destroy it. Not sure how to implement this if it's not being handled by the window server.

Name: Anonymous 2011-05-21 5:24

Objective-C
Macintosh
There's your problem(s).

Name: Anonymous 2011-05-21 5:26

>>2

Right, I forgot, /prog/ doesn't give good advice. Unfortunately any forum dedicated to Cocoa programming would shun me simply for not using Nibs and *shudder* interface builder.

Name: Anonymous 2011-05-21 5:30

>>1
I have no experience with Objective-C or Cocoa, but using a while loop there seems rather messy, and it might be what's causing the problem.
Are you sure you're not supposed to call a method on the window to make it start accepting events, or that there's no function like NSApplicationStartAndWaitUntilAllWindowsAreClosedOrSomething()?

Name: Anonymous 2011-05-21 5:41

>>4
NSApplicationStartAndWaitUntilAllWindowsAreClosedOrSomething()
ENTERPRISE

Name: Anonymous 2011-05-21 5:45

>>1
Read a book on Cocoa and stop whatever the fuck you're trying to do right now, because you're doing it maximally wrong. However as a first hint, events are processed in the event loop.

IHBT

Name: Anonymous 2011-05-21 6:04

>>6

Yes, and I'm trying to find out how to fucking create an event loop.

Name: Anonymous 2011-05-21 6:21

>>7
Go read that fucking book. Every thread has an event loop, you don't need to create one.

Name: Anonymous 2011-05-21 6:23

I have found a way to implement an event loop...

while [window isVisible] {
[window sendEvent: [window nextEventMatchingMask: NSAnyEventMask untilDate: [NSDate distantFuture] inMode: NSDefaultRunLoopMode dequeue: YES]];
}

Name: Anonymous 2011-05-21 7:09

That's some hardcore trolling right there.

Name: Anonymous 2011-05-21 15:30

>>10

What, that I'm using Objective-C with cocoa or that i'm not doing it the Apple Intended Way™

Name: Anonymous 2011-05-21 16:04

Macinto$h

Name: Anonymous 2011-05-21 16:16

>>11
You're not using Objective-C with Cocoa, you're smearing excrement over your keyboard and pretending it's what you wanted.

Name: Anonymous 2012-12-08 15:32

( ͡° ͜ʖ ͡°)

Don't change these.
Name: Email:
Entire Thread Thread List