I have got this working basically now, here is the .cpp code
void UICreateButton(String text, float x1,float y1, float x2, float y2)
{
UIButton *myButton;
NSString *StrText = text.ToNSString();
myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(x1, y1, x2, y2); // position in the parent view and set the size of the button
[myButton setTitle:StrText forState:UIControlStateNormal];
// add targets and actions
//[myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
// Add Subview to mojo window
[[[UIApplication sharedApplication] keyWindow] addSubview:myButton];
}
void UICreateTextField(String placeholder, float x1,float y1, float x2, float y2)
{
UITextField *textfield;
NSString *placeholderStr = placeholder.ToNSString();
// Create textfield
textfield = [[UITextField alloc] initWithFrame:CGRectMake(x1, y1, x2, y2)];
textfield.placeholder = placeholderStr;
//textfield.delegate = self;
textfield.returnKeyType = UIReturnKeyDone;
textfield.borderStyle = UITextBorderStyleBezel;
textfield.enablesReturnKeyAutomatically = TRUE;
// Add Subview to mojo window
[[[UIApplication sharedApplication] keyWindow] addSubview:textfield];
}
void UICreateScrollView(float ScrollViewWidth, float ScrollViewHeight, float ContentWidth, float ContentHeight)
{
UIScrollView *scrollview;
// Create scrollview
scrollview = [[UIScrollView alloc] init];
scrollview.contentSize = CGSizeMake(ContentWidth, ContentHeight);
scrollview.frame = CGRectMake(0, 0, ScrollViewWidth, ScrollViewHeight);
scrollview.scrollsToTop = NO;
//scrollview.delegate = self;
// Add Subview to mojo window
[[[UIApplication sharedApplication] keyWindow] addSubview:scrollview];
}
Add to the imonk.monkey file
Function UICreateButton(text$,x1#,y1#,x2#,y2#)
Function UICreateTextField(placeholder$, x1#, y1#, x2#,y2#)
Function UICreateScrollView(ScrollViewWidth#,ScrollViewHeight#,ContentWidth#, ContentHeight#)
|