![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
| ;|| Putting the declaration here makes the loByPass-var method-global |
#3
| |||
| |||
|
|
Frank, here is an example how to do it. But note: There are a lot more possibilities to do the same thing. Maybe another will jump in with a simpler idea. Put the code into the arrive-event on the form-level: ;|| Putting the declaration here makes the loByPass-var method-global var loByPass logical endVar method arrive(var eventInfo MoveEvent) var stRetValue string mmRet memo foInput form ui UIObject endVar if eventInfo.isPreFilter() then ;// This code executes for each object on the form doDefault ;|| Check first whether ui is a memo-field. If necessary you can apply some more restrictions ;|| To control with loByPass is necessary to avoid recursive calls. loByPass is method-global to keep the value. eventInfo.getTarget(ui) switch case ui.class <>"Field": RETURN case ui.fieldType <> "MEMO": RETURN case NOT loByPass.isAssigned(): loByPass=TRUE case loByPass: RETURN otherwise: loByPass=TRUE endSwitch ;|| Open the input-form which contains a memofield 'textbuffer' bound to a table with only one record ;|| and memofield (also named) 'textbuffer'. ;|| The input-form would probably be a dialog form with an OK-button, a CANCEL-button and a titlebar. ;|| Set in the arrive-event of the textbuffer-field: ;------------------------------------------------- ;|| if NOT self.isEdit() then self.Edit() endIf ;|| self.postAction(EditEnterMemoView) ;------------------------------------------------- ;|| open the input-form. The focus goes to the only field: 'textbuffer' if NOT foInput.open("Input") then ErrorShow("Could not open then input-form.") loByPass=FALSE RETURN endIf ;|| Set the field's name into the titlebar to control better what you're editing foInput.setTitle("Enter text for ["+ui.name+"]") ;|| Get the actual fieldvalue into the buffer foInput.Textbuffer'value=ui'value stRetValue=string(foInput.wait()) ;|| Assuming a OK-pushButton: Formreturn("OK") ;|| and another to cancel: Formreturn("False") TRY foInput.textbuffer.unlockRecord() mmRet=foInput.textbuffer foInput.close() if stRetValue<>"OK" then loByPass=FALSE RETURN endIf onFail ;|| The input-form was closed anyhow (e.g. Alt F4)) ErrorShow() loByPass=FALSE RETURN endTRY ;|| Make sure your memofield is in edit-mode: if NOT ui.isEdit() then ui.Edit() endIf ;|| Blank values don't change anything - you can do this of course another way. if NOT mmRet.isBlank() then ui.value=mmRet ui.postRecord() endIf ;|| Reset loByPass, so you can enter again this method with the next memofield you arrive at. loByPass=FALSE else ;// This code executes only for the form endIf endMethod HTH Egbert, 11:19 AM temp. in Germany |
#4
| |||
| |||
|
| Wow!!!!... WAY COOOOOL! "Set the field's name into the titlebar to control |
|
foInput.textbuffer.unlockRecord() mmRet=foInput.textbuffer <<< this gets the value from the open form foInput.close() if stRetValue<>"OK" then loByPass=FALSE RETURN endIf onFail ;|| The input-form was closed anyhow (e.g. Alt F4)) ErrorShow() loByPass=FALSE RETURN endTRY If you try to get a value from a closed form (Ctrl F4) then the method |
| onFail |
#5
| |||
| |||
|
|
Hi Frank, thank you for your personal mail. I'll answer here, so other guys may follow and add perhaps good ideas. Wow!!!!... WAY COOOOOL! "Set the field's name into the titlebar to control better what you're editing"... I like the way you think! Glad to read this ;-) snip When I <Ctrl><F4> the memoBufferForm I'm getting an error (of course I've changed some things). THE ERROR: "An error ocurred when trying to get the property named 'Value' of the object named 'MemoBuffer' of the type 'Field'. Document is not in run mode." snip 4) I don't want to use a dialog box (I hate buttons) so I used a custom form instead. Yes, keys may be faster to handle, and of course, the error is the consequence of not using buttons which return via formReturn the values "OK" resp. "False". If you use to close windows via Ctrl F4 you close the input form before the method can detect whether you wanted to cancel or to use the input. The (easily soluble) main problem is, that the method then can not get the input value this way, because it tries to read it from the yet open input form - and can't if the window is still closed. TRY foInput.textbuffer.unlockRecord() mmRet=foInput.textbuffer <<< this gets the value from the open form foInput.close() if stRetValue<>"OK" then loByPass=FALSE RETURN endIf onFail ;|| The input-form was closed anyhow (e.g. Alt F4)) ErrorShow() loByPass=FALSE RETURN endTRY If you try to get a value from a closed form (Ctrl F4) then the method branches to the onFail block. I did no further error handling in the example, only ErrorShow(). And that showed you the error message. The work around: Let all as it is, but change the code in the onFail-block: onFail ;|| The input-form was closed anyhow (e.g. Alt F4)) ;ErrorShow() <<< delete it ErrorClear() dmGet("textbuffer","textbuffer",mmRet) ;loByPass=FALSE <<< delete it ;RETURN<<< delete it endTRY Therefore you *must* add the "textbuffer.db" - or what ever name fits better for you - into the data-model of the main form. The dmGet(...) avoids a TCursor and you'll get the input-value directly from the table bound to the input memofield. If you do so, your code will be more universal. You can work with buttons or close the input-form in any other way. By the way: As the code resides in the arrive-method on form's level, you only need it once. If you don't apply more restriction it will automatically work with all memo fields on your main form. This was, I remember, what you intended, isn't it? Feel free to change or use my example. As always in our common programming field nothing is coming only from one brain. It's the stuff influenced by a lot of good willed people here since long time. HTH! Egbert, 03:04 AM. At about 05:00 PM I'll go back to Spain. |
#6
| |||
| |||
|
|
Hi Egbert, YEEEEEEEES BABY !!! ... just what the doctor ordered!... we be happening! |
![]() |
| Thread Tools | |
| Display Modes | |
| |