XWidgetSoft Forum
https://www.bbs.xwidget.com/

open locked shortcut?
https://www.bbs.xwidget.com/viewtopic.php?f=8&t=4056
Page 1 of 1

Author:  Jimking [ February 2nd, 2014, 4:22 am ]
Post subject:  open locked shortcut?

Guys, I have two png files of a safe. At the beginning I wanted to create a RB, but then I had this "crazy" idea:
Is possible to create with a script a locked folder / shortcut???

Here is my thought:
1) layer 1:png file 1-safe closed. When click on, it will show up a txt box (we can use "edit"component for this), then the user must write a certain 4 digits for example number (the default will be 0000 where the user can edit it later through the script).
2) after write the code-press Enter, will appear the layer 2, png file 2-safe open, where there will be a shortcut component of a folder or file..

What do you think? Someone crazy like me can help me?? :D

Author:  hamid [ February 2nd, 2014, 8:21 pm ]
Post subject:  Re: open locked shortcut?

so what's the problem?
i don't know any way to lock a file in xwidget
but if you want to just hide it visually (and not for security) it's easy

Author:  Jimking [ February 2nd, 2014, 8:49 pm ]
Post subject:  Re: open locked shortcut?

I'm thinking a way hamid, that somehow the layer2 will appear only when the input text have the same value of the text in the script..
I don't know if I'm clear.. (read my first post and to understand better...)
There is a script for this..? :?

Author:  meme [ February 2nd, 2014, 10:21 pm ]
Post subject:  Re: open locked shortcut?

So you want script that asks for a password when a button is clicked, then do something to a file or folder.
What exactly do you want to do to the file or folder ?
Which a file or a folder ?
Just hide it as hamid wrote ?
Or lock it so it can not be opened ?
After you open or un hide the file or folder how will it re hide or re lock ?

Author:  hamid [ February 2nd, 2014, 10:26 pm ]
Post subject:  Re: open locked shortcut?

to switch between layers:
you can do one of these:
1. Enabling and disabling visiblity of Objects:
-show the Objects you want using: [layer2.Visible=1]
-hide the objects you don't want using: [layer1.Visible=0]
2. Fliping the Object:
-use [flipObject(layer1,layer2,"")]
3. Fliping the widget
-add sides for the widget (rightClick the widget in treeView and select AddSides)
-add layer1 to FrontSide and layer2 to BackSide
-flip the widget using [widget.cmd("!Flip")]

===========
to input and check the text in editbox you can use this code:
(replace comment section with your code for changing layers)
(don't forget to add [edit1OnKeyDown] in [OnKeyDown] of function tab for edit1)
Code:
pass="1234"
function edit1OnKeyDown(Sender,Key,KeyChar,Shift)
{
  if(Key==13)
  {
    if(edit1.Text==pass)
    {
      showTrayBalloon("unlocked","5")
      edit1.Visible=0
      //use you code here to show layer2; here are some examples:
      //ex: layer2.Visible=1;
      //ex2: flipObject(layer1,layer2,"")
      //ex3: widget.cmd("!Flip")
    }
    edit1.Text=""
  }
}

===========
to limit the input to 4 character you can use this code:
(don't forget to add [edit1OnChange] in [OnChange] of function tab for edit1)
Code:
function edit1OnChange(Sender)
{
  if(edit1.Text.length>4)
  {
    edit1.Text=edit1.Text.slice(0,4)
  }
}

=============
to enable only digit input:
you can use [Filter Char>Integer] in the Attribute tab of Inspector

Author:  hamid [ February 2nd, 2014, 10:54 pm ]
Post subject:  Re: open locked shortcut?

i think he want it just for fun
to just have a view of a safe with pass code

it couldn't be used as a security; because:
1. anyone can open the script and see the password and even change the password
2. anyone can open the script and change the script to access the other layer
3. anyone can open the script and widget files to see what you hide

Author:  Jimking [ February 3rd, 2014, 5:09 am ]
Post subject:  Re: open locked shortcut?

hamid wrote:
i think he want it just for fun
to just have a view of a safe with pass code

it couldn't be used as a security; because:
1. anyone can open the script and see the password and even change the password
2. anyone can open the script and change the script to access the other layer
3. anyone can open the script and widget files to see what you hide

I know all this hamid.. Surely it will be not a real security widget, but just a little "different" widget.. Only who has installed this on his/her computer will know the trick! :)

Author:  Jimking [ February 3rd, 2014, 5:32 am ]
Post subject:  Re: open locked shortcut?

meme wrote:
So you want script that asks for a password when a button is clicked, then do something to a file or folder.
What exactly do you want to do to the file or folder ?
Which a file or a folder ?
Just hide it as hamid wrote ?
Or lock it so it can not be opened ?
After you open or un hide the file or folder how will it re hide or re lock ?

Here is my thought meme (and hamid):
1) I have these two pngs: (there is no text on them)

Image Image

2) There will be two LAYERS:
LAYER1:
- The empty icon
- When click on it (hand cursor) it will appear a txt-box (we can use "edit" component of the designer for this) where the user will have to put a 4digit num or num/letters code. This code must have, somehow using a script, the same value with the text command of the script. And after press "enter" will show up the LAYER2 (and hide the first one)
Something like:
when txtvalue 0000 = layer2 visible / hide layer1

LAYER2:
- The full icon.
- A customizable shortcut where the user can add a file or a folder.
(like a normal XWidget's shortcut)

So the main idea is to have visible the second layer only when the user will put the right text value.

It will be not a real security lock shortcut, but only who installed this on his/her pc will know the trick..

I'm not so good creating scripts, especially from the scratch, so any help will be appreciated!
Especially from you guys that you know a lot more things than me on this..
:)

Author:  hamid [ February 3rd, 2014, 9:12 am ]
Post subject:  Re: open locked shortcut?

then above script code can be used.
if you have problem with scripting:
just make the other parts of the widget and post it here,
so i can add the code for it.

Author:  Jimking [ February 3rd, 2014, 10:35 am ]
Post subject:  Re: open locked shortcut?

hamid wrote:
then above script code can be used.
if you have problem with scripting:
just make the other parts of the widget and post it here,
so i can add the code for it.

Thanks hamid! ;)
I will post the test version here soon..

Author:  Jimking [ February 3rd, 2014, 3:01 pm ]
Post subject:  Re: open locked shortcut?

Here is the test widget. I added some script by hamid but certainly needs adjusting!.. :roll:

(I added a "!ShowHideObj=edit1" onclick code, when click on the image1-layer1 so show/hide the edit panel.)

Author:  hamid [ February 4th, 2014, 12:26 am ]
Post subject:  Re: open locked shortcut?

here's the new version:
===================
fixed: ScriptCode
fixed: on pressing 5 Character, 1 of the 4character will get out of view; now all 4 characters will be shown
added: menuitem to change password
===================

Author:  Jimking [ February 4th, 2014, 4:47 am ]
Post subject:  Re: open locked shortcut?

hamid wrote:
here's the new version:
===================
fixed: ScriptCode
fixed: on pressing 5 Character, 1 of the 4character will get out of view; now all 4 characters will be shown
added: menuitem to change password
===================


You're absolutely brilliant hamid!!! :D
Just what I was thinking!
One last thing: There is a way after the safe is open put a right click option to close it again (return to the initial state)???

Author:  hamid [ February 4th, 2014, 6:30 am ]
Post subject:  Re: open locked shortcut?

There is already another menuitem that do that:
RightClick>Window>Reload


but anyway;
here's the new version:
====================
added: menuitem for locking safe again after unlocking (Only Visible when safe is unlocked)
====================

Author:  Jimking [ February 4th, 2014, 6:59 am ]
Post subject:  Re: open locked shortcut?

Yes I known about the Reload option, but I wanted something more direct, like you did! :D
Thanks a lot for the help and your fantastic job! I will make some visuals improvements and I'll post it soon..!

Author:  Jimking [ February 4th, 2014, 9:08 am ]
Post subject:  Re: open locked shortcut?

posted: :D
viewtopic.php?f=11&t=4063

Author:  meme [ February 4th, 2014, 12:10 pm ]
Post subject:  Re: open locked shortcut?

Very nice... :mrgreen:
What about a click on the center of the open door handle to lock it

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/