discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about ToolTips


From: Steve Van Voorst
Subject: Re: Question about ToolTips
Date: Sun, 2 Sep 2012 05:28:57 +0000 (GMT)

German,

I am not familiar with fisicalab and may have not understood your question correctly, but are you certain that you need to use the -mouseMoved method?  The following demo seems to work correctly on my system:

//------ start ---------
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

@interface EmbedderView : NSView
//methods automatically called
@end  //interface

@implementation EmbedderView : NSView;

-(id)initWithFrame:(NSRect)frameRect
 {
  if ((self = [super initWithFrame:frameRect]) != nil)
  {
   self = [super initWithFrame:frameRect];
   // Add initialization code here
  }
  return self;
 }

-(void)drawRect:(NSRect)rect
 {
  // ****** Background ***** //
  [[NSColor whiteColor] set];
  [NSBezierPath fillRect:rect];
 }
// ----- Use this if you want 0,0 (origin) to be top, left ---- //
// ----- Otherwise origin will be at bottom, left (Unflipped) ----- //
-(BOOL)isFlipped
 {
  return YES;
 }
@end //implementation

@interface MyDelegate : NSObject
 {
  NSWindow *window;
 }
-(void) myBtnAction: (id)sender;
-(void) createMenu;
-(void) createWindow;
@end

@implementation MyDelegate : NSObject
-(void)dealloc
 {
  [window release];
  [super dealloc];
 }

-(void)myBtnAction: (id)sender
 {
  printf ("Hello!\n");
  NSBeep();
 }

-(void) createMenu
 {
  NSMenu *menu = [[NSMenu new]autorelease];
  [menu addItemWithTitle: @"Quit"  
        action: @selector (terminate:)  
        keyEquivalent: @"q"];
  [NSApp setMainMenu: menu];
 }

-(void) createWindow
 {
  // ***** window ***** //
  #define _wndW  400
  #define _wndH  350

  window = [[NSWindow alloc] initWithContentRect: NSMakeRect( 0, 0, _wndW, _wndH )
      styleMask: NSTitledWindowMask | NSMiniaturizableWindowMask | NSClosableWindowMask
        backing: NSBackingStoreBuffered
          defer: NO];

  [window center];
  [window setTitle: @"Test window"];

  // ------- Create an instance of DrawView (NSView) ------ //
  id baseView = [[EmbedderView alloc]initWithFrame:NSMakeRect( 20, 20, _wndW - 40, _wndH - 40 )];
  [[window contentView] addSubview:baseView];
  [baseView release];

  // ****** Button1 ****** //
  NSButton *btn1 =[[NSButton alloc]initWithFrame:NSMakeRect( 30,  100, 95, 30 )];
  [btn1 setTitle: @"Make"];
  [btn1 setToolTip:@"Make"];
  [btn1 setTarget: self];
  [btn1 setAction: @selector (myBtnAction:)];
  [baseView addSubview: btn1];

  // ****** Button2 ****** //
  NSButton *btn2 =[[NSButton alloc]initWithFrame:NSMakeRect( 130,  100, 95, 30 )];
  [btn2 setTitle: @"Some"];
  [btn2 setToolTip:@"Some"];
  [btn2 setTarget: self];
  [btn2 setAction: @selector (myBtnAction:)];
  [baseView addSubview: btn2];

  // ****** Button3 ****** //
  NSButton *btn3 =[[NSButton alloc]initWithFrame:NSMakeRect( 230,  100, 95, 30 )];
  [btn3 setTitle: @"Noise"];
  [btn3 setToolTip:@"Noise"];
  [btn3 setTarget: self];
  [btn3 setAction: @selector (myBtnAction:)];
  [baseView addSubview: btn3];

  // ***** Quit btn ***** //
  NSButton *quitBtn = [[NSButton alloc]initWithFrame:NSMakeRect( 250, 250, 95, 30 )];
  [quitBtn setBezelStyle:NSRoundedBezelStyle ];
  [quitBtn setTitle: @"Quit" ];
  [quitBtn setToolTip:@"Quit"];
  [quitBtn setAction:@selector(terminate:)];
  [baseView addSubview: quitBtn];
  [quitBtn release];
 }

-(void) applicationWillFinishLaunching: (NSNotification *)not
 {
  [self createMenu];
  [self createWindow];
 }

-(void) applicationDidFinishLaunching: (NSNotification *)not;
 {
  [window makeKeyAndOrderFront: nil];
 }
@end

int main()
 {
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
  [NSApplication sharedApplication];
  [NSApp setDelegate: [MyDelegate new]];
  [NSApp run];
  [pool drain];
  return 0;
  }
 
//-------end ----------

Steve Van Voorst
reply via email to

[Prev in Thread] Current Thread [Next in Thread]