<div id="__MailbirdStyleContent" style="font-size: 12pt;font-family: Candara;color: #000000"><blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px"><p style="color: #AAAAAA; margin-top: 10px;">On 2/16/2019 8:34:21 AM, Colin McPhail <colin.mcphail@mac.com> wrote:</p><div style="font-family:Arial,Helvetica,sans-serif"><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi John,<br><br class=""></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I added a simple reimplementation of <span style="font-family: Courier">focusNextPrevChild()</span> to the <span style="font-family: Courier">EditWidget</span> class in your example:</div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-family: Courier">    def focusNextPrevChild(self, next):</span></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-family: Courier">        print(f'focusNextPrevChild({next})')</span></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-family: Courier">        text = self.text()</span></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-family: Courier">        if len(text) == 3:</span></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-family: Courier">            return False</span></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-family: Courier">        return True</span></div><div class=""><br class=""></div><div class="">This causes TAB and Shift-TAB to be ignored unless the line editor contains exactly three characters. It doesn't prevent focus moving from a partially edited cell by means of cursor movement and mouse click, however.</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Colin</div></div></div></blockquote><div><span style="font-size: 12pt;font-family: Candara;color: #000000"><span style="color: #3B5998"><br></span></span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000">Hi Colin.  Thanks for the response!</span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000"><br></span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000">This is interesting, insofar as I was unaware of </span><span style="font-size: 12pt;color: rgb(0, 0, 0)"><span style="font-family: Courier New">focusNextPrevChild()</span></span><span style="font-size: 12pt;font-family: Candara;color: #000000">, so it's new information to me.</span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000"><br></span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000">However, I already had been able to produce that effect by catching the Tab and shift-Tab keypress events (as well as the other keypress events that depart the editor cell) in the </span><span style="font-size: 12pt;color: rgb(0, 0, 0)"><span style="font-family: Courier New">EditWidget</span></span><span style="font-size: 12pt;font-family: Candara;color: #000000"> event handler.  That worked fine.</span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000"><br></span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000">Then I realized you can depart the cell by mouse movement and mouse click as well.  So I set about the task of trying to catch mouse click events and suppress them also.  That I couldn't get to work.  It was several days ago, and I can't remember the details.  But I think the problem was this:  If you click outside the edit cell, it isn't the editor widget that receives the mouse click event (which is what you'd expect, I guess).  I think it's the </span><span style="font-size: 12pt;color: rgb(0, 0, 0)"><span style="font-family: Courier New">QTableView</span></span><span style="font-size: 12pt;font-family: Candara;color: #000000"> object.  By the time the View detects the mouse click, focus has been lost already from the edit widget, and it's too late to prevent it.  [I'd have to go back and look at it again, but my recollection is that no matter how I tried to intercept mouse clicks, the editor widget always lost focus anyhow].</span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000"><br></span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000">That was what put me onto the path of trying to catch and suppress the </span><span style="font-size: 12pt;color: rgb(0, 0, 0)"><span style="font-family: Courier New">FocusOut</span></span><span style="font-size: 12pt;font-family: Candara;color: #000000"> event.  I'm keenly curious as to why what I did doesn't work.  It seems from all I've read that it should.</span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000"><br></span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000">I see there is also a </span><span style="font-size: 12pt;color: rgb(0, 0, 0)"><span style="font-family: Courier New">focusOutEvent()</span></span><span style="font-size: 12pt;font-family: Candara;color: #000000"> method that can be reimplemented.  But alas, it doesn't appear to allow any way to specify that the event should be suppressed.  I'm starting to wonder if there just isn't any way to do this.  That would surprise me ...</span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000"><br></span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000">Thanks again.</span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000"><br></span></div><div><span style="font-size: 12pt;font-family: Candara;color: #000000">/John</span></div><blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px"><div style="font-family:Arial,Helvetica,sans-serif"><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""></div></div></div></blockquote></div>