A couple of Jiggy questions

Discussion in 'Jiggy Runtime Development' started by skiier239, Aug 11, 2008.

  1. skiier239

    skiier239 New Member

    Joined:
    Feb 23, 2008
    Messages:
    35
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Hi there,

    Just wondering if any of you could help me with the code I am writing to try and teach myself how to write apps in Jiggy. Is what I am trying to do is have a selection of fonts and font sizes in separate Alert Sheets. I would like to be able to choose a font and then choose a font size.

    At the moment I am having trouble thinking how to do this as both these are on the same line of code ( Font & Font Size)

    eg.
    Code:
    hello.setFont( new Font( "verdana" , 2 , 30 ) ); 


    Here is my code for my app so far...

    Code:
    Plugins.load( "UIKit" );
    
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    window.backgroundColor = [ 0.8 , 1 , 0, 1 ];
    
    //------------------------------------------------------------------------------
    
    var mainView = new UIScroller();
    mainView.contentSize = [ window.bounds[ 1 ] * 2 , window.bounds[ 1 ] * 2 ];
    
    mainView.backgroundColor = [ 0 , 0 , 0 , 0 ];
    
    window.setContentView( mainView );
    
    //------------------------------------------------------------------------------
    
    var hello = new UITextLabel( [ 20 , 100 , window.bounds[ 2 ] -40 , 150 ] );
    
    hello.text = "Hello!";
    hello.backgroundColor = [ 0 , 0 , 0 , 0.25 ];
    hello.setFont( new Font( "verdana" , 2 , 30 ) );
    hello.color = [ 1 , 1 , 1 , 1 ];
    hello.centersHorizontally = true;
    hello.centersVertically = true;
    
    mainView.addSubview( hello );
    
    //------------------------------------------------------------------------------
    
    var bar = new UINavigationBar( [ 0 , 0 , window.bounds[ 2 ] , 48 ] );
    bar.showButtonsWithStyle( "Options" , 1 , "Change Text" , 0 );
     
    mainView.addSubview( bar );
    //------------------------------------------------------------------------------
    bar.onButtonClicked = 
    function( theBar , theButton )
    {
    if ( theButton == 0 )
    {
    as.popupAlertAnimated( true );
    }
    if ( theButton == 1 )
    {
    options.popupAlertAnimated( true );
    }
    }
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    var colour = new UIAlertSheet( "Colour Selection" , [ "Red" , "Blue" , "Black"  , "Green" , "Close" ] , 1 );
    
    colour.setBodyText( "Choose Colour Here!" );
    
    colour.setAlertSheetStyle( 0 );
    
    colour.onButtonClicked = function( button )
    {
      if ( button == 5 )
      {
      colour.dismiss( true );
      } 
      if ( button == 1 )
      {
      window.backgroundColor = [ 0.8 , 0 , 0, 1 ]
      }
      if (button == 2 )
      {
      window.backgroundColor = [ 0.8 , 1 , 1, 1 ]
      }
      if (button == 4 )
      {
      window.backgroundColor = [ 0.8 , 1 , 0, 1 ]
      }
      if (button == 3 )
      {
      window.backgroundColor = [ 0.1 , 0.1 , 0.1, 1 ]
      }
    }
    
    //------------------------------------------------------------------------------
    
    var as = new UIAlertSheet( "Custom Text" , [ "OK" , "Cancel"] , 1 );
    
    // Set the body text
    
    as.setBodyText( "Enter custom text here!" );
    
    // Change the style
    
    as.setAlertSheetStyle( 2 );
    
    var userTextField = as.addTextFieldWithValue( "" , "Type Custom Text Here" );
    
    // Button Functions
    
    as.onButtonClicked = function( button )
    {
      if ( button == 1 )
      {
      hello.text = ( as.textFieldAtIndex(0).text );
      }
        as.dismiss( true );
    }
    
    //------------------------------------------------------------------------------
    
    var options = new UIAlertSheet( "Options" , [ "Change Colour" , "Change Font" , "Change Font Size" , "Cancel"] , 1 );
    
    options.setAlertSheetStyle( 2 );
    
    options.onButtonClicked = function( button )
    {
      if ( button == 1 )
      {
      colour.popupAlertAnimated( true );
      }
      if ( button == 4 )
      {
      options.dismiss( true );
      }
      if ( button == 2 )
      {
      font.popupAlertAnimated( true );
      }
      if ( button == 3 )
      {
      size.popupAlertAnimated( true );
      }
    }
    
    //------------------------------------------------------------------------------
    
    var font = new UIAlertSheet( "Fonts" , [ "Verdana" , "Trebuchet MS" , "Ariel" , "Marker Felt" , "Close"] , 1 );
    
    font.setAlertSheetStyle( 1 );
    
    font.onButtonClicked = function( button )
    {
      if ( button == 1 )
      {
      hello.setFont( new Font( "verdana" , 2 , 30 ) );
      }
      if ( button == 2 )
      {
      hello.setFont( new Font( "trebuchet ms" , 2 , 30 ) );
      }
      if ( button == 3 )
      {
      hello.setFont( new Font( "arial" , 2 , 30 ) );
      }
      if ( button == 5 )
      {
      font.dismiss( true );
      }
      if ( button == 4 )
      {
      hello.setFont( new Font( "Marker Felt" , 2 , 30 ) );
      }
    }
    
    //------------------------------------------------------------------------------
    
    var size = new UIAlertSheet( "Font Size" , [ "20" , "30" , "40" , "50" , "Close"] , 1 );
    
    size.setAlertSheetStyle( 1 );
    
    size.onButtonClicked = function( button )
    {
      if ( button == 1 )
      {
      hello.setFont( new Font( "" , 2 , 20 ) );
      }
      if ( button == 2 )
      {
      hello.setFont( new Font( "" , 2 , 30 ) );
      }
      if ( button == 3 )
      {
      hello.setFont( new Font( "" , 2 , 40 ) );
      }
      if ( button == 5 )
      {
      size.dismiss( true );
      }
      if ( button == 4 )
      {
      hello.setFont( new Font( "" , 2 , 50 ) );
      }
    }
    Thanks in advance.

    PS - I realize that everything below size.onButtonClicked = function( button ) is pretty screwed up at the moment.
  2. OneFan

    OneFan Active Member

    Joined:
    Feb 25, 2008
    Messages:
    949
    Likes Received:
    67
    Device:
    iPhone 4 (White)
    Looks like a good start!
    I would HIGHLY recommend using UIPrefs instead of AlertSheets.
    You can find some examples of UiPrefs here and easily transfer all your codeing with ease.

    http://jiggyapp.com/download/examples/

    Just a heads up poeple are going to say..
    "DONT DEV IN JIGGY IT IS DEAD"

    In reality is not because the Runtime is being ported to OBJC and will be able to run on 2.X

    So keep your work up!
  3. skiier239

    skiier239 New Member

    Joined:
    Feb 23, 2008
    Messages:
    35
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    .

    Thanks for the advice!

    Just one question - How can I link to a page like in the UIPreferences example from the UINavigationBar button "Options"?

    Thanks heaps

    PS - Any idea of when Jiggy will appear for download in 2.0? I downgraded last week (2.0 to 1.1.4) to get Jiggy again

    Please Register or Log in to view images

    .
  4. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    It probably won't be ported to 2.x.
  5. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    http://www.ifans.com/forums/showpost.php?p=847037&postcount=26

    It's getting ported. Just the compatability though, not the interface. And it's not going to get done soon.
  6. Olle

    Olle New Member

    Joined:
    Jan 18, 2009
    Messages:
    1
    Likes Received:
    0
    Jiggy documentation

    Hi
    All links on Jiggy documentation seemes to be broken.

    Please Register or Log in to view images


    Can anybody help?
    Regards Olle

Share This Page