Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnKeyDown implemented for Form #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Best way to learn how to use the library is to look at the included **examples**
1. Make sure you have a working Go installation and build environment, see more for details on page below.
http://golang.org/doc/install

2. go get github.com/tadvi/winc
2. go get github.com/neurlang/winc

## Icons

Expand Down Expand Up @@ -94,7 +94,7 @@ Dialog screens are not based on Windows resource files (.rc). They are just wind
package main

import (
"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func main() {
Expand Down Expand Up @@ -146,15 +146,15 @@ This is usually due to string UTF8 and UTF16 conversions. But there are other ty

When developing your own controls you might also need to:

import "github.com/tadvi/winc/w32"
import "github.com/neurlang/winc/w32"

w32 has Win32 API low level constants and functions.

Look at **sample_control** for example of custom built window.

## Companion Package

[Go package for Windows Systray icon, menu and notifications](https://github.com/tadvi/systray)
[Go package for Windows Systray icon, menu and notifications](https://github.com/neurlang/systray)

## Credits

Expand Down
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"runtime"
"unsafe"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion bitmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"errors"
"unsafe"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type Bitmap struct {
Expand Down
2 changes: 1 addition & 1 deletion brush.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package winc

import (
"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

var DefaultBackgroundBrush = NewSystemColorBrush(w32.COLOR_BTNFACE)
Expand Down
2 changes: 1 addition & 1 deletion buttons.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package winc
import (
"fmt"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type Button struct {
Expand Down
2 changes: 1 addition & 1 deletion canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package winc
import (
"fmt"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type Canvas struct {
Expand Down
2 changes: 1 addition & 1 deletion combobox.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"syscall"
"unsafe"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type ComboBox struct {
Expand Down
2 changes: 1 addition & 1 deletion commondlgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"syscall"
"unsafe"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

func genOFN(parent Controller, title, filter string, filterIndex uint, initialDir string, buf []uint16) *w32.OPENFILENAME {
Expand Down
2 changes: 1 addition & 1 deletion controlbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"syscall"
"unsafe"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type ControlBase struct {
Expand Down
2 changes: 1 addition & 1 deletion controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package winc

import (
"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type Controller interface {
Expand Down
2 changes: 1 addition & 1 deletion dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package winc

import "github.com/tadvi/winc/w32"
import "github.com/neurlang/winc/w32"

// Dialog displayed as z-order top window until closed.
// It also disables parent window so it can not be clicked.
Expand Down
2 changes: 1 addition & 1 deletion edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package winc

import "github.com/tadvi/winc/w32"
import "github.com/neurlang/winc/w32"

type Edit struct {
ControlBase
Expand Down
5 changes: 4 additions & 1 deletion eventdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package winc

import (
"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type RawMsg struct {
Expand Down Expand Up @@ -43,6 +43,9 @@ type LabelEditEventData struct {
type KeyUpEventData struct {
VKey, Code int
}
type KeyDownEventData struct {
VKey, Code int
}

type SizeEventData struct {
Type uint
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_contextmenu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_control/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/sample_control/topform.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"github.com/tadvi/winc"
"github.com/tadvi/winc/w32"
"github.com/neurlang/winc"
"github.com/neurlang/winc/w32"
)

// TopForm displayed as topmost window until closed.
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_docking/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_hello/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_image/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_imagebox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_listview/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_minimal/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_scrollview/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_slider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_splitview/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_tab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample_treeview/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/tadvi/winc"
"github.com/neurlang/winc"
)

func btnOnClick(arg *winc.Event) {
Expand Down
2 changes: 1 addition & 1 deletion font.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package winc
import (
"syscall"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

const (
Expand Down
14 changes: 12 additions & 2 deletions form.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package winc

import (
"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
"unsafe"
)

Expand All @@ -24,6 +24,7 @@ type Form struct {
isFullscreen bool
previousWindowStyle uint32
previousWindowPlacement w32.WINDOWPLACEMENT
onKeyDown EventManager
}

func NewCustomForm(parent Controller, exStyle int, dwStyle uint) *Form {
Expand Down Expand Up @@ -238,8 +239,13 @@ func (fm *Form) WndProc(msg uint32, wparam, lparam uintptr) uintptr {
}
}
case w32.WM_KEYDOWN:
// Accelerator support.

// key down support.
key := Key(wparam)
code := uint32(lparam)
fm.onKeyDown.Fire(NewEvent(fm, &KeyDownEventData{VKey: int(key), Code: int(code)}))

// Accelerator support.
if uint32(lparam)>>30 == 0 {
// Using TranslateAccelerators refused to work, so we handle them
// ourselves, at least for now.
Expand Down Expand Up @@ -285,3 +291,7 @@ func (fm *Form) WndProc(msg uint32, wparam, lparam uintptr) uintptr {

return w32.DefWindowProc(fm.hwnd, msg, wparam, lparam)
}

func (fm *Form) OnKeyDown() *EventManager {
return &fm.onKeyDown
}
2 changes: 1 addition & 1 deletion globalvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package winc
import (
"syscall"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

//Private global variables.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/tadvi/winc
module github.com/neurlang/winc

go 1.12
2 changes: 1 addition & 1 deletion icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"fmt"
"syscall"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type Icon struct {
Expand Down
2 changes: 1 addition & 1 deletion imagelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package winc
import (
"fmt"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type ImageList struct {
Expand Down
2 changes: 1 addition & 1 deletion imageview.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package winc

import "github.com/tadvi/winc/w32"
import "github.com/neurlang/winc/w32"

type ImageView struct {
ControlBase
Expand Down
2 changes: 1 addition & 1 deletion imageviewbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"time"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type direction int
Expand Down
2 changes: 1 addition & 1 deletion init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package winc

import (
"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package winc
import (
"bytes"

"github.com/tadvi/winc/w32"
"github.com/neurlang/winc/w32"
)

type Key uint16
Expand Down
Loading