You are not logged in.

Jon82

Beginner

  • "Jon82" is male
  • "Jon82" started this thread

Posts: 3

Date of registration: Mar 28th 2009

Location: Norway

Occupation: Farmer

Hobbies: Programming/My girlfriend/Traveling

  • Send private message

1

Saturday, March 28th 2009, 11:06am

Event Handling

Hello all! This is cool, I have allways wanted to learn java, just for making apps that will work both in linux and windows
Now I dont need to :)
I use VB in windows and Gambas in linux
Now we got Jabaco! :thumbup:

My Question:
Is it possible to stop an event?

Example:

Public Sub rtfSend_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 10 Then
cmdSend_Click()
'Some code to stop the event to go further on...
End If
End Sub


Jon

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

2

Saturday, March 28th 2009, 9:16pm

Hi,

Quoted

allways wanted to learn java ... Now I dont need to

I would go further and say you *do* learn Java with Jabaco, because you learn the Java framework by using it.


Quoted

Is it possible to stop an event?

normally every code will go synchronously if you do not call it asynchron explicitely.

Please specify more clearly what you want to do.

greetings

OlimilO

Jon82

Beginner

  • "Jon82" is male
  • "Jon82" started this thread

Posts: 3

Date of registration: Mar 28th 2009

Location: Norway

Occupation: Farmer

Hobbies: Programming/My girlfriend/Traveling

  • Send private message

3

Sunday, March 29th 2009, 1:15pm

Thanks for giving time to help :)

I can try to express myself better (not my strongest side):

If you have a text-box, and you put some code in the key-down or key-press,
like if you pressed a key that you would not allow to appear in the text-box,
Can I abort the event, like that key dont get into the textbox?

Like I am used to from Gambas in Linux you can type:

Public Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyA Or KeyCode = vbKeyEnter Then
Stop Event 'Stops the key-event that the letter 'A' or 'Enter' dont get into the text
Exit Sub
End If
End Sub


Is that possible in Jabaco? or any other way? ?(
btw.. Jabaco is a grate application! :thumbsup: Loved it from the first day i tried it ;(

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

4

Monday, March 30th 2009, 12:18am

Filtering certain Key-strokes out of the Textbox

Hi,

Yes, what you want to do of course is possible in Jabaco, but ... it is not possible to *stop* an event (sounds crazy anyway ^^ )

for the effect you want to have, filtering certain Key-strokes out of your Textbox, you have to implement a special Interface in your Form-modul:

at the beginning of your form write:

Jabaco Source

1
Implements java#awt#Event#KeyListener


then Jabaco wants to have the following three additional Subs:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
Public Sub keyTyped(arg2 As KeyEvent)

End Sub
Public Sub keyPressed(arg2 As KeyEvent)


End Sub
Public Sub keyReleased(arg2 As KeyEvent)
   
End Sub


more over you have to inform your TextBox that now the Form-modul receives the events in this way:

Jabaco Source

1
2
3
Public Sub Form_Load()
   Text1.Parent.addKeyListener(Me)
End Sub


e.g. If you want to have only Numbers in the TextBox write the following code in the keyTyped-Event:

Jabaco Source

1
2
3
4
5
6
7
Public Sub keyTyped(arg2 As KeyEvent)
   Dim KeyCode As Integer
   KeyCode = arg2.getKeyChar
   If (KeyCode < arg2.VK_0) Or (arg2.VK_9 < KeyCode) Then
      arg2.setKeyChar(0)
   End If
End Sub


In order to get the VK_Keys- just use the Intellisense box of "arg2." and scroll down the list.

just try it!

greetings

OlimilO

Jon82

Beginner

  • "Jon82" is male
  • "Jon82" started this thread

Posts: 3

Date of registration: Mar 28th 2009

Location: Norway

Occupation: Farmer

Hobbies: Programming/My girlfriend/Traveling

  • Send private message

5

Monday, March 30th 2009, 12:00pm

Thanx OlimilO :)








Rate this thread
WoltLab Burning Board