Forum > Cocoa

Code completion in Objective Pascal

(1/1)

zbyna:
Hi all,
I am trying my first Cocoa steps:
(this program is slightly modification the one from lazarus wiki)

--- Code: ---program project1;

{$mode objfpc}{$H+}
{$modeswitch objectivec2}

uses
CocoaAll;

type
  { TMyDelegate }
  TMyDelegate = objcclass(NSObject)
  public
    procedure HandleButtonClick(sender: id); message 'HandleButtonClick:';
  end;

var
  appName: NSString;
  window: NSWindow;
  pool: NSAutoreleasePool;
  lText: NSTextField;
  lButton: NSButton;
  lDelegate: TMyDelegate;

procedure TMyDelegate.HandleButtonClick(sender: id);
begin
  lText.setStringValue(NSSTR('New text!'));
end;

begin
  // Autorelease pool, app and window creation
  pool := NSAutoreleasePool.new;
  NSApp := NSApplication.sharedApplication;
  NSApp.setActivationPolicy(NSApplicationActivationPolicyRegular);
  appName := NSProcessInfo.processInfo.processName;
  window := NSWindow.alloc.initWithContentRect_styleMask_backing_defer(NSMakeRect(0, 0, 200, 200),
    NSTitledWindowMask or NSClosableWindowMask or NSMiniaturizableWindowMask or NSResizableWindowMask,
    NSBackingStoreBuffered, False).autorelease;

  // text label
  lText := NSTextField.alloc.initWithFrame(NSMakeRect(50, 50, 120, 50)).autorelease;
  lText.setBezeled(False);
  lText.setDrawsBackground(False);
  lText.setEditable(False);
  lText.setSelectable(False);
  lText.setStringValue(NSSTR('NSTextField'));
  window.contentView.addSubview(lText);

  // button
  lButton := NSButton.alloc.initWithFrame(NSMakeRect(50, 100, 120, 50)).autorelease;
  window.contentView.addSubview(lButton);
  lButton.setTitle(NSSTR('Button title!'));
  lButton.setButtonType(NSMomentaryLightButton);
  lButton.setBezelStyle(NSRoundedBezelStyle);

  // button event handler setting
  lDelegate := TMyDelegate.alloc.init;
  lButton.setTarget(lDelegate);
  lButton.setAction(ObjCSelector(lDelegate.HandleButtonClick));

  // Window showing and app running
  window.center;
  window.setTitle(appName);
  window.makeKeyAndOrderFront(nil);
  NSApp.activateIgnoringOtherApps(true);
  NSApp.run;
end. 

--- End code ---

When I try code completion (CTRL+space) for example on:

--- Code: ---window.
--- End code ---
I would expect in ideal world  ;)  list of all NSWindow methods.
Unfornutely reality is:

--- Code: ---NSWindowScripting.inc(40,76) Error: cycle detected
--- End code ---

line 40 from NSWindowScripting.inc:

--- Code: --- NSScripting_NSWindowCategory = objccategory external name 'NSScripting' (NSWindow)
--- End code ---

Is this a bug or  some sort of behaviour which is based on differencies between ObjC and FPC model abstraction ? I am not able to judge  :-\  :( And of course the problem may be between the table and keyboard :)
Thanks for clarifying.
   zbyna

Jonas Maebe:
It's probably best to file a bug report at http://bugs.freepascal.org/set_project.php?project_id=1

zbyna:
Thanks for reply.
Reported.

Navigation

[0] Message Index

Go to full version