Widget Native Field - Andriod

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
lemodizon
Posts: 91
Joined: Thu Apr 05, 2018 3:33 pm

Widget Native Field - Andriod

Post by lemodizon » Mon Nov 30, 2020 5:16 am

Hello everyone,

I'm new to this widget native field just want to ask how to use it. I have to widget fields username and password I want to validate if the user entered the correct user name and password. Thanks in advance

Code: Select all

on mouseUp
  inputCreate
end mouseUp

on inputCreate
  if the environment is "mobile" then
    
    mobileControlCreate "input", "UserName"
    put the result into sUserName 
    
    if  sUserName is "admin" then
      answer "Hello admin"
      else 
      answer "wrong username"
    end if
  end if
Attachments
Capture1.JPG
Capture1.JPG (17.54 KiB) Viewed 1063 times
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8295
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Widget Native Field - Andriod

Post by FourthWorld » Mon Nov 30, 2020 7:11 am

Where is the password stored?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

lemodizon
Posts: 91
Joined: Thu Apr 05, 2018 3:33 pm

Re: Widget Native Field - Andriod

Post by lemodizon » Mon Nov 30, 2020 8:01 am

FourthWorld wrote:
Mon Nov 30, 2020 7:11 am
Where is the password stored?
I forgot to include in my code... can you teach me how to use this widget field. Thanks
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8295
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Widget Native Field - Andriod

Post by FourthWorld » Mon Nov 30, 2020 8:18 am

I know little about this widget field, but I know a thing or two about password management. Happy to help where I can.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

lemodizon
Posts: 91
Joined: Thu Apr 05, 2018 3:33 pm

Re: Widget Native Field - Andriod

Post by lemodizon » Mon Nov 30, 2020 9:10 am

FourthWorld wrote:
Mon Nov 30, 2020 8:18 am
I know little about this widget field, but I know a thing or two about password management. Happy to help where I can.

Hello, I just want to do in my simple app is when the user type admin and password it will go to the next card. in my code, I will assign a default username (admin) and password (12345). I noticed that there is a different approach when using the widget native field compared to a regular field. hope you can help me guys. thanks, in an advance :)
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

lemodizon
Posts: 91
Joined: Thu Apr 05, 2018 3:33 pm

Re: Widget Native Field - Andriod

Post by lemodizon » Mon Nov 30, 2020 3:06 pm

lemodizon wrote:
Mon Nov 30, 2020 9:10 am
FourthWorld wrote:
Mon Nov 30, 2020 8:18 am
I know little about this widget field, but I know a thing or two about password management. Happy to help where I can.

Hello, I just want to do in my simple app is when the user type admin and password it will go to the next card. in my code, I will assign a default username (admin) and password (12345). I noticed that there is a different approach when using the widget native field compared to a regular field. hope you can help me guys. thanks, in an advance :)

Hello everyone,

Is there a bug in the widget android native field? how can I get the inputted text in this field? I don't know if I can use the field here coz there is a problem with the keyboard sometimes it doesn't appear.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8295
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Widget Native Field - Andriod

Post by FourthWorld » Mon Nov 30, 2020 4:27 pm

Who is the intended audience for this admin feature?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5785
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Widget Native Field - Andriod

Post by jacque » Mon Nov 30, 2020 10:16 pm

There are two ways to create an Android field. The first way is to use mobileControlCreate. The second way is to use the field widget in the tool palette which you drag onto the card. Your image looks like you are using the widget, but the code looks like you are creating a native field by script. You can't mix the two.

You need to write scripts that read the user input which you'd probably do in the Enter button. When the user taps the button, get the text of the fields and see if it is correct. The syntax is:

Code: Select all

get the text of widget "password"
You can see all the messages and properties in the dictionary if you search for "Android native field".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

lemodizon
Posts: 91
Joined: Thu Apr 05, 2018 3:33 pm

Re: Widget Native Field - Andriod

Post by lemodizon » Fri Dec 04, 2020 11:07 am

jacque wrote:
Mon Nov 30, 2020 10:16 pm
There are two ways to create an Android field. The first way is to use mobileControlCreate. The second way is to use the field widget in the tool palette which you drag onto the card. Your image looks like you are using the widget, but the code looks like you are creating a native field by script. You can't mix the two.

You need to write scripts that read the user input which you'd probably do in the Enter button. When the user taps the button, get the text of the fields and see if it is correct. The syntax is:

Code: Select all

get the text of widget "password"
You can see all the messages and properties in the dictionary if you search for "Android native field".
Hello Jacque,

Thanks for the information. most of the example I saw in the internet they are using this "mobileControlCreate". I'm trying the second way you said. Is there a example or link using this syntax in android?
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5785
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Widget Native Field - Andriod

Post by jacque » Fri Dec 04, 2020 6:57 pm

It's simple enough that I doubt there is a lesson. Drag a field widget to the card and name it "user". Drag another to the card and name it "password".

In the Enter button, create a mouseUp handler.

Code: Select all

on mouseUp 
  put the text of widget "user" into tUser
  put the text of widget "password" into tPass
  - - here, compare the values to the correct responses 
  - - and take action if they are correct 
end mouseUp 
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

lemodizon
Posts: 91
Joined: Thu Apr 05, 2018 3:33 pm

Re: Widget Native Field - Andriod

Post by lemodizon » Sat Dec 05, 2020 4:19 am

jacque wrote:
Fri Dec 04, 2020 6:57 pm
It's simple enough that I doubt there is a lesson. Drag a field widget to the card and name it "user". Drag another to the card and name it "password".

In the Enter button, create a mouseUp handler.

Code: Select all

on mouseUp 
  put the text of widget "user" into tUser
  put the text of widget "password" into tPass
  - - here, compare the values to the correct responses 
  - - and take action if they are correct 
end mouseUp 

Hi Jacque,

there is wrong in my previous code instead "put" i typed the "get" that's why it's not working. this is now ok. Thanks again and stay safe.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5785
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Widget Native Field - Andriod

Post by jacque » Sat Dec 05, 2020 5:38 am

Great! Good luck with your app.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

lemodizon
Posts: 91
Joined: Thu Apr 05, 2018 3:33 pm

Re: Widget Native Field - Andriod

Post by lemodizon » Sat Dec 05, 2020 9:21 am

jacque wrote:
Sat Dec 05, 2020 5:38 am
Great! Good luck with your app.
Hi Jacque,

How can I get the text of the datagrid going to my widget? i tried this code noting happens

Code: Select all

if EditProd is "EditProd" then
            put the dgHilitedLine of group "DataProd" into tLineToEdit 
            
            if tLineToEdit is empty then
               beep
               Answer info "Please select a Product name to EDIT INFORMATION" 
            else
               if tLineToEdit is a number and tLineToEdit >0 then
                  
                  set the itemdel to tab
                  put line tLineToEdit of the dgtext of grp "DataProd" of cd "MainCard" of stack "MyAndriod" into tData
                               
                  put the text item 1 of tdata into widget "ProdPrice" of cd "EditProd"
                                        
                    go to card "EditProd"
                  
               end if
Attachments
Capture.JPG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

Klaus
Posts: 12124
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Widget Native Field - Andriod

Post by Klaus » Sat Dec 05, 2020 12:14 pm

Hi lemodizon,

do this:

Code: Select all

...
   ## If you do not have an ELSE case for this IF -> if EditProd is "EditProd" then
   ## you should avoid many IF THENs, this makes the script better readable!
   if EditProd <> "EditProd" then
      exit mouseup 
      ## or what handler we are currently in
   end if
   
   ## Now check hilite:
   put the dgHilitedLine of group "DataProd" into tLineToEdit
   if tLineToEdit = empty then
      beep
      Answer info "Please select a Product name to EDIT INFORMATION" 
      exit mouseup 
      ## See above
   end if
   
   ## It is easier to work with an array, since datagrids do this, too, internally!
   put the dgDataOfline[tLineToEdit] of grp "DataProd" into tArray
   
   ## This array tArray has the names of the columns as its KEYS, so we can easily 
   put tArray["price"] into tPrice
   put tArray["productname"] into tProdName
   ## etc. for all infos from the datagrid
   ## Change the name if they do not fit your column name, I am only guessing from the screenshot.
   
   ## Widget are a different beast so we need to set THE TEXT and not "put into...":
   set the text of widget "ProdPrice" of cd "EditProd" to tPrice   
   set the text of widget "ProdName" of cd "EditProd" to tProdName
   ## etc. see above...
   go to card "EditProd"
...
Best

Klaus

lemodizon
Posts: 91
Joined: Thu Apr 05, 2018 3:33 pm

Re: Widget Native Field - Andriod

Post by lemodizon » Sat Dec 12, 2020 3:52 am

Klaus wrote:
Sat Dec 05, 2020 12:14 pm
Hi lemodizon,

do this:

Code: Select all

...
   ## If you do not have an ELSE case for this IF -> if EditProd is "EditProd" then
   ## you should avoid many IF THENs, this makes the script better readable!
   if EditProd <> "EditProd" then
      exit mouseup 
      ## or what handler we are currently in
   end if
   
   ## Now check hilite:
   put the dgHilitedLine of group "DataProd" into tLineToEdit
   if tLineToEdit = empty then
      beep
      Answer info "Please select a Product name to EDIT INFORMATION" 
      exit mouseup 
      ## See above
   end if
   
   ## It is easier to work with an array, since datagrids do this, too, internally!
   put the dgDataOfline[tLineToEdit] of grp "DataProd" into tArray
   
   ## This array tArray has the names of the columns as its KEYS, so we can easily 
   put tArray["price"] into tPrice
   put tArray["productname"] into tProdName
   ## etc. for all infos from the datagrid
   ## Change the name if they do not fit your column name, I am only guessing from the screenshot.
   
   ## Widget are a different beast so we need to set THE TEXT and not "put into...":
   set the text of widget "ProdPrice" of cd "EditProd" to tPrice   
   set the text of widget "ProdName" of cd "EditProd" to tProdName
   ## etc. see above...
   go to card "EditProd"
...
Best

Klaus
Hi Klaus,

Thanks, This is now ok. Stay safe.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”