1. Button problem...

I'm trying to make this so that yo type into the WritenJ only when your 
in the edit mode. But I can't seem to get the interpeture to figure out 
which mode it is in so that it dose the right procedures.

sequence lBuffer
lBuffer=""
Journal = create( PushButton, "Journal", Window1, 588, 0, 90, 30, 0 ),
    JWIN = create( Window, "Journal", 0, Default, Default, 252, 336+ 19, 
0 ),
    WritenJ = create( MleText, "", JWIN, 9, 13, 224, 272, 0 ),
    EditJ = create( PushButton, "Ok", JWIN, 16, 292, 90, 30, 0 ),
    JCancel = create( PushButton, "Cancel", JWIN, 124, 292, 90, 30, 0 )
procedure onClick_Journal()
openWindow(JWIN, Normal)
setText( WritenJ, lBuffer )
end procedure
onClick[ Journal ] = routine_id( "onClick_Journal" )

procedure onClick_EditJ()
--in edit mode switch out and save text.
if equal(getText(EditJ) , "Ok" ) then
setText( lBuffer, WritenJ )
setText( EditJ, "Edit" )
--not in edit mode switch with no text.
elsif equal(getText(EditJ), "Edit" ) then
setText( WritenJ, "" )
setText( EditJ, "Edit" )
end if
end procedure
onClick[ EditJ ] = routine_id( "onClick_EditJ" )

procedure onclick_Jcancel()
closeWindow( JWIN )
end procedure
onClick[Jcancel] = routine_id( "onClick_EditJ" )
WinMain( Journal, Normal )

new topic     » topic index » view message » categorize

2. Re: Button problem...

----- Original Message -----
From: <engale2000 at hotmail.com>
To: "EUforum" <EUforum at topica.com>
Subject: Button problem...


>
> I'm trying to make this so that yo type into the WritenJ only when your
> in the edit mode. But I can't seem to get the interpeture to figure out
> which mode it is in so that it dose the right procedures.
>
> sequence lBuffer
> lBuffer=""
> Journal = create( PushButton, "Journal", Window1, 588, 0, 90, 30, 0 ),
>     JWIN = create( Window, "Journal", 0, Default, Default, 252, 336+ 19,
> 0 ),
>     WritenJ = create( MleText, "", JWIN, 9, 13, 224, 272, 0 ),
>     EditJ = create( PushButton, "Ok", JWIN, 16, 292, 90, 30, 0 ),
>     JCancel = create( PushButton, "Cancel", JWIN, 124, 292, 90, 30, 0 )
> procedure onClick_Journal()
> openWindow(JWIN, Normal)
> setText( WritenJ, lBuffer )
> end procedure
> onClick[ Journal ] = routine_id( "onClick_Journal" )
>
> procedure onClick_EditJ()
> --in edit mode switch out and save text.
> if equal(getText(EditJ) , "Ok" ) then
> setText( lBuffer, WritenJ )
> setText( EditJ, "Edit" )
> --not in edit mode switch with no text.
> elsif equal(getText(EditJ), "Edit" ) then
> setText( WritenJ, "" )
> setText( EditJ, "Edit" )
> end if
> end procedure
> onClick[ EditJ ] = routine_id( "onClick_EditJ" )
>
> procedure onclick_Jcancel()
> closeWindow( JWIN )
> end procedure
> onClick[Jcancel] = routine_id( "onClick_EditJ" )
> WinMain( Journal, Normal )
>
>
>

Hi Engale,
I've included an updated version of your code.

The main changes are ...

  --  Initially set the edittext area to disabled with a gray background,
and have the button read "Edit".

  -- When the button is pressed
  --   if it says "Edit" then it means that the user wants to go INTO edit
mode
  --       so I clear the edit field, set the field to enabled, set the
color to white, change the button to say "Ok", and move the focus to the
edit field.
  --   if it says "Ok" then it means that the user wants to go OUTOF edit
mode
  --       so I save the entered text, set the field to disabled, set the
color to gray and change the button to say "Edit"
  --


----------
 include win32lib.ew
 sequence lBuffer

 lBuffer=""
 constant
 Window1 = create(Window, "", 0, 0, 0, 800, 500, 0),
 Journal = create( PushButton, "Journal", Window1, 588, 0, 90, 30, 0 ),
    JWIN = create( Window, "Journal", 0, Default, Default, 252, 336+ 19,
 0 ),
    WritenJ = create( MleText, "", JWIN, 9, 13, 224, 272, 0 ),
    EditJ = create( PushButton, "Edit", JWIN, 16, 292, 90, 30, 0 ),
    JCancel = create( PushButton, "Cancel", JWIN, 124, 292, 90, 30, 0 )
 procedure onClick_Journal()
    openWindow(JWIN, Normal)
    setText( WritenJ, lBuffer )
 end procedure
 onClick[ Journal ] = routine_id( "onClick_Journal" )

 procedure onClick_EditJ()
 --in edit mode switch out and save text.
 if equal(getText(EditJ) , "Ok" ) then
    lBuffer = getText(  WritenJ )
    setText( EditJ, "Edit" )
    setEnable( WritenJ, 0)
    setWindowBackColor(WritenJ, getSysColor(COLOR_BTNFACE))
 --not in edit mode switch with no text.
 elsif equal(getText(EditJ), "Edit" ) then
    setText( WritenJ, "" )
    setText( EditJ, "Ok" )
    setEnable( WritenJ, 1)
    setWindowBackColor(WritenJ, getSysColor(COLOR_WINDOW))
    setFocus( WritenJ)
 end if
 end procedure
 onClick[ EditJ ] = routine_id( "onClick_EditJ" )

 procedure onclick_Jcancel()
    closeWindow( JWIN )
 end procedure
 onClick[JCancel] = routine_id( "onClick_EditJ" )

 setEnable(WritenJ, 0)
 setWindowBackColor(WritenJ, getSysColor(COLOR_BTNFACE))
 WinMain( Window1, Normal )

 ----------
cheers,
Derek

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu