Skip to content

The Contextmenu Doesn't Work Properly. #15

Description

@nperovic

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)
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions