Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Scripting    what's wrong with this script ?
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Apprentice
Posted
hi, i'm new with fscript, can some1 help with this? daylite crashes eachtime i click on the button. i tried this script on a normal fscript-console & it works quite well ( just change NSPupupButtons items for something else instead if getting it from DB:


"Instantiate and configure a window"
window := NSWindow alloc initWithContentRectfrowne125<>513 extent:383<>175)
styleMask:NSTitledWindowMask + NSClosableWindowMask + NSMiniaturizableWindowMask
backing:NSBackingStoreBuffered
defer:NO.

"Put the window onscreen"
window orderFront:nil.

"Give a title to the window"
window setTitle:'Test'.

"Instantiate a form object"
form := NSForm alloc initWithFramefrowne15<>70 extent:348<>85).

"Put the form into the window"
window contentView addSubview:form.

"Configure the form"
popup := NSPopUpButton alloc initWithFramefrowne20<>20 extent:200<>100) pullsDown:NO.
cats := objectContext objectsForEntityNamed:'Category'.

catCount := cats count.
msg:='get' ++ (catCount description) ++ 'categories' ++ '\n'.

index:= 0.
[index < catCount] whileTrue:
[
cat := cats objectAtIndex:index.
catName := cat name.
popup addItemWithTitle:catName.
msg := msg ++ (catName) ++ '\n'.
index:= index + 1.
].


"button"
button := NSButton alloc initWithFramefrowne247<>15 extent:100<>60).
window contentView addSubview:button.
button setBezelStyle:NSRoundedBezelStyle.
button setTitle:'get Contacts'.

"label"

text := NSTextField alloc initWithFramefrowne20<>90 extent:90<>30).
text setEditable:YES.
text setStringValue:'test'.

catSelected := [
text setStringValue: (popup titleOfSelectedItem).
].

window contentView addSubviewrazzopup.
window contentView addSubview:text.

button setTarget: catSelected.

button setAction:#value:.


---
thanx
 
Posts: 3 | Location: Munich | Registered: May 27, 2007Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
Sorry for the delay in answering this.

After correcting a few syntax thing (because of the html), it seems to render fine for me.

I'm not sure what you want to accomplish though.

From the looks of it, a plugin might be better because I think you will need a couple of classes. Add classes in F-Script is not easy however (there are ways, but it is not for the faint of heart).

Here is my cleaned up code:
"Instantiate and configure a window"
window := NSWindow alloc initWithContentRect:(125<>513 extent:383<>175) styleMask:NSTitledWindowMask + NSClosableWindowMask + NSMiniaturizableWindowMask backing:NSBackingStoreBuffered defer:NO.

"Put the window onscreen"
window orderFront:nil.

"Give a title to the window"
window setTitle:'Test'.

"Instantiate a form object"
form := NSForm alloc initWithFrame:(15<>70 extent:348<>85).

"Put the form into the window"
window contentView addSubview:form.

"Configure the form"
popup := NSPopUpButton alloc initWithFrame:(20<>20 extent:200<>100) pullsDown:NO.	
cats := objectContext objectsForEntityNamed:'Category'.

catCount := cats count.
msg:='get' ++ (catCount description) ++ 'categories' ++ '\n'.

index:= 0.
[index < catCount] whileTrue:
[
cat := cats objectAtIndex:index.
catName := cat name.
popup addItemWithTitle:catName.
msg := msg ++ (catName) ++ '\n'.
index:= index + 1.
].


"button"
button := NSButton alloc initWithFrame:(247<>15 extent:100<>60).
window contentView addSubview:button.
button setBezelStyle:NSRoundedBezelStyle.
button setTitle:'get Contacts'.

"label"

text := NSTextField alloc initWithFrame:(20<>90 extent:90<>30).
text setEditable:YES.
text setStringValue:'test'.

catSelected := [
text setStringValue: (popup titleOfSelectedItem).
].

window contentView addSubview:popup.
window contentView addSubview:text.

button setTarget: catSelected.

button setAction:#value:.
  
 
Posts: 891 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
I think
button setAction:#value:.


is the problem.

Considering you know all this cocoa stuff, I would go with a plugin, bindings and a nib.
 
Posts: 891 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Scripting    what's wrong with this script ?

© Copyright 2006 Marketcircle Inc. All rights reserved.