Sign in to follow this  
Reperior

Problema con la ColorWell

Recommended Posts

vi spiego:


file.h



//
// TheViewer.h
// The Writer
//
// Created by Imac on 17/11/13.
// Copyright (c) 2013 Imac. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface TheViewer : NSObject
{
NSColor *daColor;

IBOutlet NSTextField *textField;
IBOutlet NSTextField *viewer;
IBOutlet NSColorWell *well;
/* IBOutlet NSSlider *redSlider;
IBOutlet NSSlider *blueSlider;
IBOutlet NSSlider *greenSlider; */

}

- (IBAction)sendText:(id)sender;
- (IBAction)deleteText:(id)sender;
- (IBAction)changeColor:(NSColorWell *)sender;


@end


file.m



//
// TheViewer.m
// The Writer
//
// Created by Imac on 17/11/13.
// Copyright (c) 2013 Imac. All rights reserved.
//

#import "TheViewer.h"

@implementation TheViewer

- (id)init
{
self = [super init];
if (self) {

}
return self;
}

- (IBAction)changeColor:(NSColorWell *)sender
{

daColor = sender.color;


}

- (IBAction)sendText:(id)sender
{

NSString *testo = [textField stringValue];
[viewer setStringValue:testo];
[viewer setTextColor:daColor];




/*NSString *theItem = [NSString stringWithFormat:@"%@",[popup titleOfSelectedItem]];

if([theItem isEqualToString:@"Red"])
{
[viewer setTextColor:[NSColor redColor]];
}
if([theItem isEqualToString:@"Blue"])
{
[viewer setTextColor:[NSColor blueColor]];
}

if([theItem isEqualToString:@"Yellow"])
{
[viewer setTextColor:[NSColor yellowColor]];
}
*/


}

- (IBAction)deleteText:(id)sender
{
[viewer setStringValue:@""];
}

- (IBAction)settingColor:(id)sender
{
[viewer setTextColor:sender];
}

@end


Non trovo un modo per far sì che quando l'utente clicca un pulsante il metodo sendText imposti il colore del testo che poi manderà. QUalcuno che possa suggerirmi?


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this