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

The Contextmenu Doesn't Work Properly. #15

Open
nperovic opened this issue Aug 10, 2023 · 0 comments
Open

The Contextmenu Doesn't Work Properly. #15

nperovic opened this issue Aug 10, 2023 · 0 comments

Comments

@nperovic
Copy link

https://github.com/G33kDude/RichCode.ahk/blob/9a54252d193dbafeccb86b9e751cb36c8c8f5548/RichCode.ahk#L207-L241

I apologise for not being able to point out exactly where the problem is, but this is what I have done so far to fix it.
I'm sure you'll understand as soon as you see it.

; Create the right click menu
this.menu := Menu()
for Index, Entry in RichCode.MenuItems
	this.menu.Add(Entry?, IsSet(Entry) ? RightClickMenu : unset)

; Get the ITextDocument object
bufpIRichEditOle := Buffer(A_PtrSize, 0)
this.SendMsg(0x43C, 0, bufpIRichEditOle) ; EM_GETOLEINTERFACE
this.pIRichEditOle := NumGet(bufpIRichEditOle, "UPtr")
this.IRichEditOle := ComValue(9, this.pIRichEditOle, 1)
; ObjAddRef(this.pIRichEditOle)
this.pITextDocument := ComObjQuery(this.IRichEditOle, RichCode.IID_ITextDocument)
this.ITextDocument := ComValue(9, this.pITextDocument, 1)
; ObjAddRef(this.pITextDocument)

RightClickMenu(ItemName, ItemPos, MenuName)
{
	Switch ItemName {
	case "Cut"       : A_Clipboard := this.SelectedText, this.SelectedText := ""
	case "Copy"      : A_Clipboard := this.SelectedText
	case "Paste"     : this.SelectedText := A_Clipboard
	case "Delete"    : this.SelectedText := ""
	case "Select All": this.Selection    := [0, -1]
	case "UPPERCASE" : this.SelectedText := Format("{:U}", this.SelectedText)
	case "lowercase" : this.SelectedText := Format("{:L}", this.SelectedText)
	case "TitleCase" : this.SelectedText := Format("{:T}", this.SelectedText)
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant