Author Topic: KeyPad Location  (Read 1706 times)

Mongoid

  • Newbie
  • *
  • Posts: 3
    • View Profile
KeyPad Location
« on: March 15, 2015, 01:33:27 AM »
Hi Folks,

How can I set a location property for the pop up keyboard? Keeping in mind I'm an absolute beginner to .net. I would like it to pop up in another location other than the center of the screen.

Having a lot of fun with what I've been able to figure out so far. Amazing job Archie. Runs great on a Raspberry PI II. Have the PI running AHMI on a 27" screen and a lil' Weintek 4" HMI attached (ethernet) to a Micro 820 and they play very nicely together.

Thanks,

Mongoid

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: KeyPad Location
« Reply #1 on: March 15, 2015, 07:40:01 AM »
- Open BasicLabel.vb in the Controls folder of the AdvancedHMIControls project
- Go to line 605
- Modify the code like this:
Code: [Select]
KeypadPopUp.StartPosition = Windows.Forms.FormStartPosition.Manual
 KeypadPopUp.StartPosition = New Point(10, 10)
 KeypadPopUp.TopMost = True

Mongoid

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: KeyPad Location
« Reply #2 on: March 15, 2015, 10:09:43 AM »
Morning Archie,

Thanks again for your fast response. Changing the code as above should have the keypad opening at top left (I'm assuming the New Point (10, 10) are the x,y co-ordinates)?

I have changed the code, saved all and rebuilt the project but the keyboard still pops up in the center of the screen. Any idea what I have missed?

Thanks,

Mongoid

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: KeyPad Location
« Reply #3 on: March 15, 2015, 10:58:11 AM »
That actually won't work. I forgot when the AlphaNumeric keypad option was added, it took away that possibility. I added the capability back in. It will be part of the next release of 3.98a that will be available later this week.

Mongoid

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: KeyPad Location
« Reply #4 on: March 15, 2015, 11:10:40 AM »
Thanks Archie

OK. Cool.

Is there a way to permanently add Layout/Location to the Properties of the keypad? I suppose this might be better asked under Feature requests...

Thanks again,

Mongoid


Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: KeyPad Location
« Reply #5 on: March 15, 2015, 03:32:06 PM »
Here is a new property code that worked for me:

Code: [Select]
    Public Property KeypadLocation() As FormStartPosition
        Get
            Return Me.m_KeypadLocation
        End Get
        Set(ByVal value As FormStartPosition)
            'If value = FormStartPosition.WindowsDefaultBounds Then value = FormStartPosition.CenterScreen
            Me.m_KeypadLocation = value
            Me.Invalidate()
        End Set
    End Property


The choice of WindowsDefaultBounds had slight "paint-all-over" effect so I included an extra line to swap it for another choice (if you are experiencing the same and don't like it then just enable this line).

Then just change the line 601 (or 605 or whatever number) from:

KeypadPopUp.StartPosition = Windows.Forms.FormStartPosition.CenterScreen

to:

KeypadPopUp.StartPosition = Me.m_KeypadLocation
« Last Edit: March 15, 2015, 03:57:23 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: KeyPad Location
« Reply #6 on: March 15, 2015, 10:26:59 PM »
This option might be more correct in somebody's opinion:

Code: [Select]
    Enum StartPosition
        TopLeft
        CenterParent
        CenterScreen
    End Enum

    Private fsp As New FormStartPosition
    Private m_KeypadLocation As StartPosition = StartPosition.TopLeft
    Public Property KeypadLocation() As StartPosition
        Get
            Return Me.m_KeypadLocation
        End Get
        Set(ByVal value As StartPosition)
            If value = StartPosition.TopLeft Then fsp = FormStartPosition.Manual
            If value = StartPosition.CenterParent Then fsp = FormStartPosition.CenterParent
            If value = StartPosition.CenterScreen Then fsp = FormStartPosition.CenterScreen
            Me.m_KeypadLocation = value
            Me.Invalidate()
        End Set
    End Property

And change the line 605 to:

KeypadPopUp.StartPosition = fsp