Salut tout le monde,NSTextField non modifiable dans la coutume NSWindow
Si je crée NSTextField dans la vue de mon contrôleur alors tout va bien - le champ est modifiable. Malheureusement, je dois créer NSTextField dans NSWindow personnalisé. Mon code ci-dessous produit un champ qui ressemble sans focus (la sélection de texte est grise) et qui n'est pas éditable (pas de curseur et pas de réaction aux touches). Je peux changer la sélection de texte avec la souris mais c'est tout.
Dois-je activer le NSWindow pour recevoir des frappes de touches?
apprécie votre aide, --Josef
NSRect windowRect = [[self.window contentView] frame] ;
NSWindow* uiWindow = [[NSWindow alloc] initWithContentRect:windowRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered defer:YES];
[uiWindow setBackgroundColor: [NSColor redColor/*clearColor*/]];
[uiWindow setOpaque:NO];
NSView* uiView = [[[NSView alloc] initWithFrame:NSMakeRect(0, 0, windowRect.size.width, windowRect.size.height)] autorelease];
[uiView translateOriginToPoint:NSMakePoint(100, uiView.bounds.size.height/2)];
uiView.wantsLayer = YES;
[uiWindow setContentView:uiView];
NSTextField *textField;
textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 800, 80)];
[textField setFont:[NSFont fontWithName:@"Helvetica Bold" size:60]];
[textField setStringValue:@"My Label"];
[textField setBezeled:YES];
[textField setDrawsBackground:YES];
[textField setEditable:YES];
[textField setSelectable:YES];
[textField setEnabled:YES];
[uiView addSubview:textField];
// THIS DOES NOT WORK
[self.window addChildWindow:uiWindow ordered:NSWindowAbove];
// THIS WORKS
//[_graphicView addSubview:uiView];
Je viens de trouver qu'il est causé par window styleMask NSBorderlessWindowMask. Si j'utilise NSTitledWindowMask alors ça va. Est-il possible d'activer le clavier pour une fenêtre sans bordure? –