// MIT Licence http://en.wikipedia.org/wiki/MIT_License // //Copyright 2015 Maurice Inzirillo - AJAR SA //http://www.ajar.ch // //Permission is hereby granted, free of charge, to any person obtaining //a copy of this software and associated documentation files (the //"Software"), to deal in the Software without restriction, including //without limitation the rights to use, copy, modify, merge, publish, //distribute, sublicense, and/or sell copies of the Software, and to //permit persons to whom the Software is furnished to do so, subject to //the following conditions: // //The above copyright notice and this permission notice shall be //included in all copies or substantial portions of the Software. // //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, //EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF //MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND //NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE //LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION //OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION //WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ---------------------------------------------------- // Method : JVFloatLabeledTextField // // Description // I recently discovered the Mobile Form Interaction // - http://dribbble.com/shots/1254439--GIF-Mobile-Form-Interaction?list=users // by Matt D. Smith, and try to port them into 4D // // Update Ortwin Zillgen 4. march 2015 // Parameter : "name of textobject" // You need to create or copy and paste from the test_Form // the object $jvfObjName and set the style if you want to // change the current style. // For each field for which you want to display // the "float info" you must activate the object events : // - On Load // - On Clicked // - On Getting Focus // - On Losing Focus // - On Data Change // on After Edit // // ---------------------------------------------------- C_TEXT($Float_info_field_name;$jvfObjName;$1;$txt;$labelPlaceholder) C_POINTER($vp_t_JVF_obj;$P_mySelf;$P_Object) C_LONGINT($Float_info_activ_color;$Float_info_inactiv_color;$i;$left;$top;$right;$bottom;$left_JVF;$top_JVF;$right_JVF;$bottom_JVF;$delta_L) $delta_L:=3 // adjust distance labelbottom above fieldtop If (Count parameters>=1) $jvfObjName:=$1 Else $jvfObjName:="JVF_obj" // if you standardize on a text-object name End if $Float_info_activ_color:=0x4080 //Float info active color $Float_info_inactiv_color:=0x00AAAAAA //Float info inactive color $P_mySelf:=OBJECT Get pointer(Object with focus) // Pointer to field/Var $Float_info_field_name:=OBJECT Get name(Object with focus)+$jvfObjName // set a name for the float info field Case of : (Nil($P_mySelf)) : ((Type($P_mySelf->)#Is alpha field) & (Type($P_mySelf->)#Is text) & (Type($P_mySelf->)#Is string var)) : ($P_mySelf->#"") // Get Placeholder $labelPlaceholder:=OBJECT Get placeholder($P_mySelf->) End case Case of : (Form event=On Load) OBJECT GET COORDINATES(*;$jvfObjName;$left_JVF;$top_JVF;$right_JVF;$bottom_JVF) ARRAY TEXT($t_ObjNames;0) ARRAY POINTER($t_P_Objects;0) ARRAY LONGINT($t_Pages_L;0) FORM GET OBJECTS($t_ObjNames;$t_P_Objects;$t_Pages_L;*) For ($i;1;Size of array($t_ObjNames)) // creaing labelobjects for objects with placeholders $P_Object:=$t_P_Objects{$i} If (Nil($P_Object)) // you'll get that Else $placeholder:=OBJECT Get placeholder($P_Object->) If ($placeholder#"") //Positioning the float info above the target Field $Float_info_field_name:=$t_ObjNames{$i}+$jvfObjName OBJECT GET COORDINATES($P_Object->;$left;$top;$right;$bottom) OBJECT DUPLICATE(*;$jvfObjName;$Float_info_field_name;$left;$top-($bottom_JVF-$top_JVF)-$delta_L;$right;$top;*) OBJECT SET TITLE(*;$Float_info_field_name;"") // initialisize label to "" End if End if End for : (Nil($P_mySelf)) : (Undefined($P_mySelf->)) // for those who let the compiler define vars : (Form event=On Clicked) & ($P_mySelf->#"") OBJECT SET RGB COLORS(*;$Float_info_field_name;$Float_info_activ_color;Background color none) // set the active color : (Form event=On Losing Focus) OBJECT SET RGB COLORS(*;$Float_info_field_name;$Float_info_inactiv_color;Background color none) // set the color of the float info field to grey : (Form event=On Getting Focus) & ($P_mySelf->#"") OBJECT SET RGB COLORS(*;$Float_info_field_name;$Float_info_activ_color;Background color none) // set the active color : (Form event=On After Edit) OBJECT SET RGB COLORS(*;$Float_info_field_name;$Float_info_activ_color;Background color none) // set the active color $labelPlaceholder:=Get edited text If ($labelPlaceholder="") // no data. The placeholder info is back ! Else $labelPlaceholder:=OBJECT Get placeholder($P_mySelf->) End if Else End case OBJECT SET TITLE(*;$Float_info_field_name;$labelPlaceholder) // ----- ENDE JVFloatLabeledTextField ------